diff --git a/test/e2e/scheduling/framework.go b/test/e2e/scheduling/framework.go index fc248872217..55e28f220c6 100644 --- a/test/e2e/scheduling/framework.go +++ b/test/e2e/scheduling/framework.go @@ -44,7 +44,7 @@ func SIGDescribe(text string, body func()) bool { func WaitForStableCluster(c clientset.Interface, workerNodes sets.String) int { startTime := time.Now() // Wait for all pods to be scheduled. - allScheduledPods, allNotScheduledPods := getScheduledAndUnscheduledPods(c, workerNodes, metav1.NamespaceAll) + allScheduledPods, allNotScheduledPods := getScheduledAndUnscheduledPods(c, workerNodes) for len(allNotScheduledPods) != 0 { time.Sleep(waitTime) if startTime.Add(timeout).Before(time.Now()) { @@ -55,7 +55,7 @@ func WaitForStableCluster(c clientset.Interface, workerNodes sets.String) int { framework.Failf("Timed out after %v waiting for stable cluster.", timeout) break } - allScheduledPods, allNotScheduledPods = getScheduledAndUnscheduledPods(c, workerNodes, metav1.NamespaceAll) + allScheduledPods, allNotScheduledPods = getScheduledAndUnscheduledPods(c, workerNodes) } return len(allScheduledPods) } @@ -78,10 +78,11 @@ func WaitForPodsToBeDeleted(c clientset.Interface) { } } -// getScheduledAndUnscheduledPods lists scheduled and not scheduled pods in the given namespace, with succeeded and failed pods filtered out. -func getScheduledAndUnscheduledPods(c clientset.Interface, workerNodes sets.String, ns string) (scheduledPods, notScheduledPods []v1.Pod) { - pods, err := c.CoreV1().Pods(ns).List(context.TODO(), metav1.ListOptions{}) - framework.ExpectNoError(err, fmt.Sprintf("listing all pods in namespace %q while waiting for stable cluster", ns)) +// getScheduledAndUnscheduledPods lists scheduled and not scheduled pods in all namespaces, with succeeded and failed pods filtered out. +func getScheduledAndUnscheduledPods(c clientset.Interface, workerNodes sets.String) (scheduledPods, notScheduledPods []v1.Pod) { + pods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{}) + framework.ExpectNoError(err, fmt.Sprintf("listing all pods in namespace %q while waiting for stable cluster", metav1.NamespaceAll)) + // API server returns also Pods that succeeded. We need to filter them out. filteredPods := make([]v1.Pod, 0, len(pods.Items)) for _, p := range pods.Items {