@@ -571,7 +571,7 @@ var _ = SIGDescribe("StatefulSet", func() {
571
571
e2esset .WaitForRunningAndNotReady (c , * ss .Spec .Replicas , ss )
572
572
e2esset .WaitForStatusReadyReplicas (c , ss , 0 )
573
573
e2esset .UpdateReplicas (c , ss , 3 )
574
- e2esset . ConfirmStatefulPodCount (c , 1 , ss , 10 * time .Second , true )
574
+ confirmStatefulPodCount (c , 1 , ss , 10 * time .Second , true )
575
575
576
576
ginkgo .By ("Scaling up stateful set " + ssName + " to 3 replicas and waiting until all of them will be running in namespace " + ns )
577
577
e2esset .RestoreHTTPProbe (c , ss )
@@ -604,7 +604,7 @@ var _ = SIGDescribe("StatefulSet", func() {
604
604
e2esset .WaitForStatusReadyReplicas (c , ss , 0 )
605
605
e2esset .WaitForRunningAndNotReady (c , 3 , ss )
606
606
e2esset .UpdateReplicas (c , ss , 0 )
607
- e2esset . ConfirmStatefulPodCount (c , 3 , ss , 10 * time .Second , true )
607
+ confirmStatefulPodCount (c , 3 , ss , 10 * time .Second , true )
608
608
609
609
ginkgo .By ("Scaling down stateful set " + ssName + " to 0 replicas and waiting until none of pods will run in namespace" + ns )
610
610
e2esset .RestoreHTTPProbe (c , ss )
@@ -651,7 +651,7 @@ var _ = SIGDescribe("StatefulSet", func() {
651
651
e2esset .WaitForRunningAndNotReady (c , * ss .Spec .Replicas , ss )
652
652
e2esset .WaitForStatusReadyReplicas (c , ss , 0 )
653
653
e2esset .UpdateReplicas (c , ss , 3 )
654
- e2esset . ConfirmStatefulPodCount (c , 3 , ss , 10 * time .Second , false )
654
+ confirmStatefulPodCount (c , 3 , ss , 10 * time .Second , false )
655
655
656
656
ginkgo .By ("Scaling up stateful set " + ssName + " to 3 replicas and waiting until all of them will be running in namespace " + ns )
657
657
e2esset .RestoreHTTPProbe (c , ss )
@@ -662,7 +662,7 @@ var _ = SIGDescribe("StatefulSet", func() {
662
662
e2esset .WaitForStatusReadyReplicas (c , ss , 0 )
663
663
e2esset .WaitForRunningAndNotReady (c , 3 , ss )
664
664
e2esset .UpdateReplicas (c , ss , 0 )
665
- e2esset . ConfirmStatefulPodCount (c , 0 , ss , 10 * time .Second , false )
665
+ confirmStatefulPodCount (c , 0 , ss , 10 * time .Second , false )
666
666
667
667
ginkgo .By ("Scaling down stateful set " + ssName + " to 0 replicas and waiting until none of pods will run in namespace" + ns )
668
668
e2esset .RestoreHTTPProbe (c , ss )
@@ -1163,3 +1163,26 @@ func rollbackTest(c clientset.Interface, ns string, ss *appsv1.StatefulSet) {
1163
1163
priorRevision ))
1164
1164
}
1165
1165
}
1166
+
1167
+ // confirmStatefulPodCount asserts that the current number of Pods in ss is count, waiting up to timeout for ss to
1168
+ // to scale to count.
1169
+ func confirmStatefulPodCount (c clientset.Interface , count int , ss * appsv1.StatefulSet , timeout time.Duration , hard bool ) {
1170
+ start := time .Now ()
1171
+ deadline := start .Add (timeout )
1172
+ for t := time .Now (); t .Before (deadline ); t = time .Now () {
1173
+ podList := e2esset .GetPodList (c , ss )
1174
+ statefulPodCount := len (podList .Items )
1175
+ if statefulPodCount != count {
1176
+ e2epod .LogPodStates (podList .Items )
1177
+ if hard {
1178
+ e2elog .Failf ("StatefulSet %v scaled unexpectedly scaled to %d -> %d replicas" , ss .Name , count , len (podList .Items ))
1179
+ } else {
1180
+ e2elog .Logf ("StatefulSet %v has not reached scale %d, at %d" , ss .Name , count , statefulPodCount )
1181
+ }
1182
+ time .Sleep (1 * time .Second )
1183
+ continue
1184
+ }
1185
+ e2elog .Logf ("Verifying statefulset %v doesn't scale past %d for another %+v" , ss .Name , count , deadline .Sub (t ))
1186
+ time .Sleep (1 * time .Second )
1187
+ }
1188
+ }
0 commit comments