Skip to content

use the /scale subresource to when updating replica count#16540

Merged
knative-prow[bot] merged 2 commits intoknative:mainfrom
dprotaso:scale-subresource
Apr 16, 2026
Merged

use the /scale subresource to when updating replica count#16540
knative-prow[bot] merged 2 commits intoknative:mainfrom
dprotaso:scale-subresource

Conversation

@dprotaso
Copy link
Copy Markdown
Member

@dprotaso dprotaso commented Apr 15, 2026

This replaces #16419

Fixes #15528

Some notable differences

  • don't use the scale client Get since that is an API call - we don't want to do that for every scale call.
    • use the existing PodScalable resource which has the currentScale
  • Drop spec.template from PodScalable since we don't need it to scale the resource
    • This saves memory in the autoscaler and controller
  • This has the added benefit of not having to DeepCopy and computing a
    JSONPatch via diffing two json byte strings which would take about 400ms

For now we expected the spec.replicas to be the patch required to update the replica count.

Note: we don't use the scale client to Get the resource prior since it will hit the API server

Release Note

Autoscaler now supports CRDs that implement the `/scale` subresource for updating

This has the added benefit of not having to deepcopy and computing a
JSONPatch via diffing two json byte strings which would take about 400ms
@knative-prow knative-prow Bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 15, 2026
@knative-prow knative-prow Bot requested review from dsimansk and skonto April 15, 2026 20:34
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.23%. Comparing base (8badc85) to head (0f85a06).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #16540      +/-   ##
==========================================
+ Coverage   80.15%   80.23%   +0.08%     
==========================================
  Files         217      217              
  Lines       13547    13532      -15     
==========================================
- Hits        10859    10858       -1     
+ Misses       2319     2310       -9     
+ Partials      369      364       -5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This property is no longer needed by the autoscaler so we don't need to
store the PodTemplate in memory
@dprotaso dprotaso changed the title [wip] use the /scale subresource to when updating replica count use the /scale subresource to when updating replica count Apr 15, 2026
@knative-prow knative-prow Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 15, 2026
@dprotaso
Copy link
Copy Markdown
Member Author

/assign @linkvt

resourceNames: ["knative-serving-certmanager"]
- apiGroups: ["*"]
resources: ["*/scale"]
verbs: ["patch"]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dprotaso I assume, this is intentionally wide to allow for scaling different resourecs like mentioned in the issue CloneSet, AppSet. Correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's the intent

@dsimansk
Copy link
Copy Markdown
Contributor

/lgtm

For other reviewers
/hold

@knative-prow knative-prow Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 16, 2026
@knative-prow knative-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 16, 2026
Copy link
Copy Markdown
Contributor

@linkvt linkvt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, clean change - didn't expect it to be that simple!

Also didn't know that the JSON Patch add operation is more forgiving than replace 💡

/lgtm

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented Apr 16, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dprotaso, linkvt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@dprotaso
Copy link
Copy Markdown
Member Author

/hold cancel

@knative-prow knative-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 16, 2026
@knative-prow knative-prow Bot merged commit 90e684d into knative:main Apr 16, 2026
72 checks passed
@chenzhiguo
Copy link
Copy Markdown

👍

@dprotaso dprotaso deleted the scale-subresource branch April 17, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhance the scalability of multi-type workloads

4 participants