Visitar URL original
Deployment stuck indefinitely when scaling during rolling update with maxSurge=0 due to stale annotations · Issue #135483 · kubernetes/kubernetes · GitHub
Skip to content

Deployment stuck indefinitely when scaling during rolling update with maxSurge=0 due to stale annotations #135483

Closed as not planned

Description

@SDkie

What happened?

When a Deployment is scaled down during an in-progress rolling update (with maxSurge=0),
the deployment controller gets stuck in an infinite loop and the rolling update never completes.

The issue occurs because:

  1. During a rolling update, ReplicaSet annotations (deployment.kubernetes.io/desired-replicas)
    are set to the initial deployment size
  2. If the deployment is scaled down while the update is in progress, the replica count changes
    but the annotations remain stale
  3. isScalingEvent() detects the annotation mismatch and returns true, causing the controller
    to call sync() instead of rolloutRolling()
  4. scale() checks if replica counts match and returns early without updating annotations
    (lines 303-304 in pkg/controller/deployment/sync.go)
  5. scaleReplicaSetAndRecordEvent() also has an early return when replicas match (lines 400-401)
  6. The annotations are never updated, creating an infinite loop

This prevents the rolling update from proceeding. Pods remain on the old version indefinitely, and there are no error messages.

Impact: Applications cannot be updated, security patches cannot be deployed, and the
deployment appears healthy while being completely stuck.

What did you expect to happen?

The deployment controller should update ReplicaSet annotations even when replica counts
already match the desired state. After scaling during a rolling update, the controller should:

  1. Detect the annotation mismatch
  2. Update the stale annotations to match the current deployment.spec.replicas
  3. Continue with the rolling update by calling rolloutRolling()
  4. Create a new ReplicaSet with the updated template
  5. Complete the rolling update successfully

The annotations should be kept in sync with deployment.spec.replicas regardless of whether
the replica count changed, to ensure isScalingEvent() correctly identifies true scaling
events versus stale annotation states.

How can we reproduce it (as minimally and precisely as possible)?

Automated Reproduction

Run this automated verification script which reproduces the bug from scratch:

curl -fsSL https://gist.githubusercontent.com/SDkie/eb9527f434b5556fdf77f9a4207c56fc/raw/b9195d738eb5b99b8f1931818699ebe0378b9be9/gistfile1.txt | bash

The script will:

  • Create a kind cluster
  • Deploy a test application with maxSurge=0, maxUnavailable=1
  • Simulate the stale annotation condition
  • Trigger a rolling update
  • Demonstrate that the update is blocked

Anything else we need to know?

No response

Kubernetes version

  • Tested on self hosted cluster on 1.29 version
  • Tested on kind cluster on 1.32 version

Issue still exists in the latest code.

Cloud provider

  • Tested on self hosted / self managed Uber clusters
    (I work in Uber compute team)

OS version

No response

Install tools

No response

Container runtime (CRI) and version (if applicable)

No response

Related plugins (CNI, CSI, ...) and versions (if applicable)

No response

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug.
    on Nov 27, 2025
  2. added
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.
    on Nov 27, 2025
  3. k8s-ci-robot commented on Nov 27, 2025

    @k8s-ci-robot
    Contributor

    This issue is currently awaiting triage.

    If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

    The triage/accepted label can be added by org members by writing /triage accepted in a comment.

    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.

  4. P-Sreeshanth commented on Nov 28, 2025

    @P-Sreeshanth

    /sig apps

  5. added
    sig/appsCategorizes an issue or PR as relevant to SIG Apps.
    and removed
    needs-sigIndicates an issue or PR lacks a `sig/foo` label and requires one.
    on Nov 28, 2025
  6. k8s-triage-robot commented on Feb 26, 2026

    @k8s-triage-robot

    The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle stale
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle stale

  7. added
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Feb 26, 2026
  8. added 4 commits that reference this issue on Mar 26, 2026
    2515dd1
    b2474c6
    d74d16c
    cea3b68
  9. k8s-triage-robot commented on Mar 28, 2026

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

    This bot triages un-triaged issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Mark this issue as fresh with /remove-lifecycle rotten
    • Close this issue with /close
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /lifecycle rotten

  10. added
    lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.
    and removed
    lifecycle/staleDenotes an issue or PR has remained open with no activity and has become stale.
    on Mar 28, 2026
  11. k8s-triage-robot commented on Apr 27, 2026

    @k8s-triage-robot

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

  12. k8s-ci-robot commented on Apr 27, 2026

    @k8s-ci-robot
    Contributor

    @k8s-triage-robot: Closing this issue, marking it as "Not Planned".

    Details

    In response to this:

    The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

    This bot triages issues according to the following rules:

    • After 90d of inactivity, lifecycle/stale is applied
    • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
    • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

    You can:

    • Reopen this issue with /reopen
    • Mark this issue as fresh with /remove-lifecycle rotten
    • Offer to help out with Issue Triage

    Please send feedback to sig-contributor-experience at kubernetes/community.

    /close not-planned

    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.

  13. moved this from Needs Triage to Closed in SIG Appson Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugCategorizes issue or PR as related to a bug.lifecycle/rottenDenotes an issue or PR that has aged beyond stale and will be auto-closed.needs-triageIndicates an issue or PR lacks a `triage/foo` label and requires one.sig/appsCategorizes an issue or PR as relevant to SIG Apps.

    Type

    No type

    Projects

    • Status
      Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions