Skip to content

Commit 9fe3a4c

Browse files
lmicciniclaude
andcommitted
Require all pods updated before reporting IsReady
During rolling updates, ReadyReplicas can match the desired count while UpdatedReplicas lags behind — old pods are still ready but running stale config. Add UpdatedReplicas == Spec.Replicas to both deployment.IsReady() and statefulset.IsReady() so consumers (e.g. transport secret rotation guards) don't act on stale readiness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d3778a5 commit 9fe3a4c

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

modules/common/deployment/deployment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,12 @@ func GetDeploymentWithName(
132132
// IsReady - validates when deployment is ready deployed to whats being requested
133133
// - the requested replicas in the spec matches the ReadyReplicas of the status
134134
// - the Status.Replicas match Status.ReadyReplicas. if a deployment update is in progress, Replicas > ReadyReplicas
135+
// - all pods run the current spec (UpdatedReplicas == requested replicas)
135136
// - both when the Generatation of the object matches the ObservedGeneration of the Status
136137
func IsReady(deployment appsv1.Deployment) bool {
137138
return deployment.Spec.Replicas != nil &&
138139
*deployment.Spec.Replicas == deployment.Status.ReadyReplicas &&
140+
*deployment.Spec.Replicas == deployment.Status.UpdatedReplicas &&
139141
deployment.Status.Replicas == deployment.Status.ReadyReplicas &&
140142
deployment.Generation == deployment.Status.ObservedGeneration
141143
}

modules/common/statefulset/statefulset.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,11 @@ func (s *StatefulSet) Delete(
152152

153153
// IsReady - validates when deployment is ready deployed to whats being requested
154154
// - the requested replicas in the spec matches the ReadyReplicas of the status
155+
// - all pods run the current spec (UpdatedReplicas == requested replicas)
155156
// - both when the Generatation of the object matches the ObservedGeneration of the Status
156157
func IsReady(deployment appsv1.StatefulSet) bool {
157158
return deployment.Spec.Replicas != nil &&
158159
*deployment.Spec.Replicas == deployment.Status.ReadyReplicas &&
160+
*deployment.Spec.Replicas == deployment.Status.UpdatedReplicas &&
159161
deployment.Generation == deployment.Status.ObservedGeneration
160162
}

0 commit comments

Comments
 (0)