@@ -39,46 +39,34 @@ func WaitForStableCluster(c clientset.Interface, masterNodes sets.String) int {
39
39
timeout := 10 * time .Minute
40
40
startTime := time .Now ()
41
41
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 {
48
45
time .Sleep (2 * time .Second )
49
-
50
- scheduledSystemPods , currentlyNotScheduledSystemPods := getSystemPods (c )
51
- systemPods = scheduledSystemPods + currentlyNotScheduledSystemPods
52
- allPods = getAllPods (c )
53
-
54
46
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
+ }
55
51
framework .Failf ("Timed out after %v waiting for stable cluster." , timeout )
56
52
break
57
53
}
54
+ allScheduledPods , allNotScheduledPods = getFilteredPods (c , masterNodes , metav1 .NamespaceAll )
58
55
}
59
- return scheduledSystemPods
56
+ return len ( allScheduledPods )
60
57
}
61
58
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 {})
65
62
framework .ExpectNoError (err , "listing all pods in kube-system namespace while waiting for stable cluster" )
66
63
// 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 {
69
66
if pod .Status .Phase != v1 .PodSucceeded && pod .Status .Phase != v1 .PodFailed {
70
- currentPods = append (currentPods , pod )
67
+ filteredPods = append (filteredPods , pod )
71
68
}
72
-
73
69
}
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 )
84
72
}
0 commit comments