@@ -570,6 +570,7 @@ type operatorInfo struct {
570570
571571// scaleOperatorsDown scales the specified operators down to 0 replicas by order
572572func scaleOperatorsDown (oc * exutil.CLI , operators []operatorInfo ) {
573+ ctx := context .Background ()
573574 for _ , op := range operators {
574575 g .By (fmt .Sprintf ("Scaling down %s in namespace %s" , op .name , op .namespace ))
575576 err := oc .AsAdmin ().Run ("scale" ).Args (
@@ -578,6 +579,29 @@ func scaleOperatorsDown(oc *exutil.CLI, operators []operatorInfo) {
578579 "--replicas=0" ,
579580 ).Execute ()
580581 o .Expect (err ).NotTo (o .HaveOccurred (), "failed to scale down %s" , op .name )
582+
583+ // Wait for the deployment to actually scale down to 0 pods
584+ g .By (fmt .Sprintf ("Waiting for %s pods to terminate" , op .name ))
585+ o .Eventually (func () bool {
586+ deployment , err := oc .AdminKubeClient ().AppsV1 ().Deployments (op .namespace ).Get (ctx , op .name , metav1.GetOptions {})
587+ if err != nil {
588+ e2e .Logf ("Failed to get deployment %s/%s: %v" , op .namespace , op .name , err )
589+ return false
590+ }
591+ e2e .Logf ("Deployment %s/%s: spec.replicas=%d, status.replicas=%d, ready=%d, available=%d" ,
592+ op .namespace , op .name , * deployment .Spec .Replicas , deployment .Status .Replicas ,
593+ deployment .Status .ReadyReplicas , deployment .Status .AvailableReplicas )
594+
595+ // Ensure spec.replicas is still 0 (hasn't been reconciled back)
596+ // and all pods (including terminating) are gone
597+ return deployment .Spec .Replicas != nil &&
598+ * deployment .Spec .Replicas == 0 &&
599+ deployment .Generation == deployment .Status .ObservedGeneration &&
600+ deployment .Status .Replicas == 0 &&
601+ deployment .Status .AvailableReplicas == 0
602+ }).WithTimeout (eniWaitTimeout ).WithPolling (eniPollInterval ).Should (o .BeTrue (),
603+ "Deployment %s should have spec.replicas=0 and status.replicas=0" , op .name )
604+
581605 e2e .Logf ("Successfully scaled down %s" , op .name )
582606 }
583607}
0 commit comments