Skip to content

Commit 0067e2b

Browse files
committed
fix: wait until deployment stabilizes to set status Ready
Signed-off-by: Mario Valderrama <[email protected]>
1 parent 3865226 commit 0067e2b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/resources/k8s_deployment_resource.go

+15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
appsv1 "k8s.io/api/apps/v1"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11+
"k8s.io/utils/ptr"
1112
"sigs.k8s.io/controller-runtime/pkg/client"
1213
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1314

@@ -102,10 +103,24 @@ func (r *KubernetesDeploymentResource) isProgressingUpgrade() bool {
102103
return true
103104
}
104105

106+
// An update is complete when new pods are ready and old pods deleted.
107+
desired := ptr.Deref(r.resource.Spec.Replicas, 2)
105108
if r.resource.Status.UnavailableReplicas > 0 {
106109
return true
107110
}
108111

112+
if r.resource.Status.UpdatedReplicas != desired {
113+
return true
114+
}
115+
116+
if r.resource.Status.ReadyReplicas != desired {
117+
return true
118+
}
119+
120+
if r.resource.Status.Replicas != desired {
121+
return true
122+
}
123+
109124
return false
110125
}
111126

0 commit comments

Comments
 (0)