@@ -394,15 +394,24 @@ var _ = SIGDescribe("SchedulerPreemption [Serial]", func() {
394
394
// satisfy the pod topology spread constraints. Hence it needs to preempt another low pod
395
395
// to make the Pods spread like [<high>, <medium, low>].
396
396
runPausePod (f , mediumPodCfg )
397
- e2epod .WaitForPodNotPending (cs , ns , mediumPodCfg .Name )
398
397
399
398
ginkgo .By ("Verify there are 3 Pods left in this namespace" )
400
399
wantPods := sets .NewString ("high" , "medium" , "low" )
401
400
402
- podList , err := cs .CoreV1 ().Pods (ns ).List (context .TODO (), metav1.ListOptions {})
403
- pods := podList .Items
401
+ var pods []v1.Pod
402
+ // Wait until the number of pods stabilizes. Note that `medium` pod can get scheduled once the
403
+ // second low priority pod is marked as terminating.
404
+ // TODO: exact the wait.PollImmediate block to framework.WaitForNumberOfRunningPods.
405
+ err := wait .PollImmediate (framework .Poll , framework .PollShortTimeout , func () (bool , error ) {
406
+ podList , err := cs .CoreV1 ().Pods (ns ).List (context .TODO (), metav1.ListOptions {})
407
+ // ignore intermittent network error
408
+ if err != nil {
409
+ return false , nil
410
+ }
411
+ pods = podList .Items
412
+ return len (pods ) == 3 , nil
413
+ })
404
414
framework .ExpectNoError (err )
405
- framework .ExpectEqual (len (pods ), 3 )
406
415
407
416
for _ , pod := range pods {
408
417
// Remove the ordinal index for low pod.
0 commit comments