Skip to content

Commit ed3cc6a

Browse files
authored
Merge pull request kubernetes#84988 from ahg-g/ahg-stablecluster
Revert changes to WaitForStableCluster in scheduler e2e test
2 parents ff4718e + f4e4fb1 commit ed3cc6a

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

test/e2e/scheduling/framework.go

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,34 @@ func WaitForStableCluster(c clientset.Interface, masterNodes sets.String) int {
3939
timeout := 10 * time.Minute
4040
startTime := time.Now()
4141

42-
allPods := getAllPods(c)
43-
scheduledSystemPods, currentlyNotScheduledSystemPods := getSystemPods(c)
44-
systemPods := scheduledSystemPods + currentlyNotScheduledSystemPods
45-
46-
// Wait for system pods to be scheduled, and for pods in all other namespaces to be deleted
47-
for currentlyNotScheduledSystemPods != 0 || systemPods != allPods {
42+
// Wait for all pods to be scheduled.
43+
allScheduledPods, allNotScheduledPods := getFilteredPods(c, masterNodes, metav1.NamespaceAll)
44+
for len(allNotScheduledPods) != 0 {
4845
time.Sleep(2 * time.Second)
49-
50-
scheduledSystemPods, currentlyNotScheduledSystemPods := getSystemPods(c)
51-
systemPods = scheduledSystemPods + currentlyNotScheduledSystemPods
52-
allPods = getAllPods(c)
53-
5446
if startTime.Add(timeout).Before(time.Now()) {
47+
framework.Logf("Timed out waiting for the following pods to schedule")
48+
for _, p := range allNotScheduledPods {
49+
framework.Logf("%v/%v", p.Namespace, p.Name)
50+
}
5551
framework.Failf("Timed out after %v waiting for stable cluster.", timeout)
5652
break
5753
}
54+
allScheduledPods, allNotScheduledPods = getFilteredPods(c, masterNodes, metav1.NamespaceAll)
5855
}
59-
return scheduledSystemPods
56+
return len(allScheduledPods)
6057
}
6158

62-
// getAllPods lists all pods in the cluster, with succeeded and failed pods filtered out and returns the count
63-
func getAllPods(c clientset.Interface) int {
64-
allPods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(metav1.ListOptions{})
59+
// getFilteredPods lists scheduled and not scheduled pods in the given namespace, with succeeded and failed pods filtered out.
60+
func getFilteredPods(c clientset.Interface, masterNodes sets.String, ns string) (scheduledPods, notScheduledPods []v1.Pod) {
61+
pods, err := c.CoreV1().Pods(ns).List(metav1.ListOptions{})
6562
framework.ExpectNoError(err, "listing all pods in kube-system namespace while waiting for stable cluster")
6663
// API server returns also Pods that succeeded. We need to filter them out.
67-
currentPods := make([]v1.Pod, 0, len(allPods.Items))
68-
for _, pod := range allPods.Items {
64+
filteredPods := make([]v1.Pod, 0, len(pods.Items))
65+
for _, pod := range pods.Items {
6966
if pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
70-
currentPods = append(currentPods, pod)
67+
filteredPods = append(filteredPods, pod)
7168
}
72-
7369
}
74-
allPods.Items = currentPods
75-
return len(allPods.Items)
76-
}
77-
78-
// getSystemPods lists the pods in the kube-system namespace and returns the number of scheduled and unscheduled pods
79-
func getSystemPods(c clientset.Interface) (int, int) {
80-
systemPods, err := c.CoreV1().Pods(metav1.NamespaceSystem).List(metav1.ListOptions{})
81-
framework.ExpectNoError(err, "listing all pods in kube-system namespace while waiting for stable cluster")
82-
scheduledSystemPods, currentlyNotScheduledSystemPods := e2epod.GetPodsScheduled(masterNodes, systemPods)
83-
return len(scheduledSystemPods), len(currentlyNotScheduledSystemPods)
70+
pods.Items = filteredPods
71+
return e2epod.GetPodsScheduled(masterNodes, pods)
8472
}

0 commit comments

Comments
 (0)