File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
pkg/controllers/workapplier Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -133,7 +133,8 @@ func trackDeploymentAvailability(inMemberClusterObj *unstructured.Unstructured)
133133 }
134134 if deploy .Status .ObservedGeneration == deploy .Generation &&
135135 requiredReplicas == deploy .Status .AvailableReplicas &&
136- requiredReplicas == deploy .Status .UpdatedReplicas {
136+ requiredReplicas == deploy .Status .UpdatedReplicas &&
137+ deploy .Status .UnavailableReplicas == 0 {
137138 klog .V (2 ).InfoS ("Deployment is available" , "deployment" , klog .KObj (inMemberClusterObj ))
138139 return ManifestProcessingAvailabilityResultTypeAvailable , nil
139140 }
Original file line number Diff line number Diff line change @@ -212,6 +212,17 @@ func TestTrackDeploymentAvailability(t *testing.T) {
212212 UpdatedReplicas : 2 ,
213213 }
214214
215+ // new replicaset due to max surge, is not ready. old replicaset is still ready.
216+ unavailableDeployWithMoreReplicasThanRequired := deploy .DeepCopy ()
217+ unavailableDeployWithMoreReplicasThanRequired .Spec .Replicas = ptr .To (int32 (1 ))
218+ unavailableDeployWithMoreReplicasThanRequired .Status = appsv1.DeploymentStatus {
219+ // we don't use this field in the availability check, adding for test case clarity.
220+ Replicas : 2 ,
221+ AvailableReplicas : 1 ,
222+ UpdatedReplicas : 1 ,
223+ UnavailableReplicas : 1 ,
224+ }
225+
215226 testCases := []struct {
216227 name string
217228 deploy * appsv1.Deployment
@@ -242,6 +253,11 @@ func TestTrackDeploymentAvailability(t *testing.T) {
242253 deploy : unavailableDeployWithNotEnoughUpdatedReplicas ,
243254 wantManifestProcessingAvailabilityResultType : ManifestProcessingAvailabilityResultTypeNotYetAvailable ,
244255 },
256+ {
257+ name : "unavailable deployment with unavailable replicas" ,
258+ deploy : unavailableDeployWithMoreReplicasThanRequired ,
259+ wantManifestProcessingAvailabilityResultType : ManifestProcessingAvailabilityResultTypeNotYetAvailable ,
260+ },
245261 }
246262
247263 for _ , tc := range testCases {
You can’t perform that action at this time.
0 commit comments