Skip to content

Respect DesiredScale in checkAndUpdateDeployment for scaled-to-zero services#16612

Open
ayushh0311 wants to merge 1 commit into
knative:mainfrom
ayushh0311:fix/scaled-to-zero-persistence
Open

Respect DesiredScale in checkAndUpdateDeployment for scaled-to-zero services#16612
ayushh0311 wants to merge 1 commit into
knative:mainfrom
ayushh0311:fix/scaled-to-zero-persistence

Conversation

@ayushh0311
Copy link
Copy Markdown

Fix scaled-to-zero services restarting on node preemption (re: #12538)

Modified checkAndUpdateDeployment to respect the PodAutoscaler's DesiredScale when available.

Fixes

#12538

Proposed Changes

  • Modified checkAndUpdateDeployment in pkg/reconciler/revision/cruds.go to query the PodAutoscaler's DesiredScale status instead of blindly preserving the Deployment's current replica count
  • During node disruptions, the revision reconciler now respects the autoscaler's scaling decisions, preventing scaled-to-zero services from restarting
  • Added fallback to preserve deployment replicas when PodAutoscaler DesiredScale is unavailable (maintains backward compatibility)
  • Added unit tests in pkg/reconciler/revision/cruds_test.go covering scale-to-zero preservation, scale-up scenarios, and backward compatibility

Release Note

Fixed an issue where scaled-to-zero Knative services would restart when spot/preemptible nodes were preempted and replaced. The revision reconciler now respects the PodAutoscaler's desired scale decision when updating deployments, preventing unintended pod recreation during node disruptions.

…start (re: knative#12538) :Modified checkAndUpdateDeployment to respect the PodAutoscaler's DesiredScale when available
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 25, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ayushh0311 / name: supernova0311 (d690442)

@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 25, 2026

Welcome @ayushh0311! It looks like this is your first PR to knative/serving 🎉

@knative-prow knative-prow Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 25, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 25, 2026

Hi @ayushh0311. Thanks for your PR.

I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@knative-prow knative-prow Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label May 25, 2026
@knative-prow
Copy link
Copy Markdown

knative-prow Bot commented May 25, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ayushh0311
Once this PR has been reviewed and has the lgtm label, please assign skonto for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@knative-prow knative-prow Bot requested review from dprotaso, dsimansk and skonto May 25, 2026 17:54
@dprotaso
Copy link
Copy Markdown
Member

Modified checkAndUpdateDeployment in pkg/reconciler/revision/cruds.go to query the PodAutoscaler's DesiredScale status instead of blindly preserving the Deployment's current replica count

The deployment's replica count is set by the PodAutoscaler's reconciler - so in my opinion the changes in this PR doesn't have any affect.

@dprotaso
Copy link
Copy Markdown
Member

/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 May 25, 2026
@dprotaso
Copy link
Copy Markdown
Member

@ayushh0311 what observations do you have regarding these changes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

2 participants