Skip to content

Commit 9902021

Browse files
committed
Fix a PodTopologySpread e2e flake
1 parent 24bf9e0 commit 9902021

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

test/e2e/scheduling/preemption.go

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,15 +394,24 @@ var _ = SIGDescribe("SchedulerPreemption [Serial]", func() {
394394
// satisfy the pod topology spread constraints. Hence it needs to preempt another low pod
395395
// to make the Pods spread like [<high>, <medium, low>].
396396
runPausePod(f, mediumPodCfg)
397-
e2epod.WaitForPodNotPending(cs, ns, mediumPodCfg.Name)
398397

399398
ginkgo.By("Verify there are 3 Pods left in this namespace")
400399
wantPods := sets.NewString("high", "medium", "low")
401400

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+
})
404414
framework.ExpectNoError(err)
405-
framework.ExpectEqual(len(pods), 3)
406415

407416
for _, pod := range pods {
408417
// Remove the ordinal index for low pod.

0 commit comments

Comments
 (0)