mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Revert changes to WaitForStableCluster in scheduler e2e test
This commit is contained in:
parent
557275f1d1
commit
f4e4fb1fc8
@ -39,46 +39,34 @@ func WaitForStableCluster(c clientset.Interface, masterNodes sets.String) int {
|
|||||||
timeout := 10 * time.Minute
|
timeout := 10 * time.Minute
|
||||||
startTime := time.Now()
|
startTime := time.Now()
|
||||||
|
|
||||||
allPods := getAllPods(c)
|
// Wait for all pods to be scheduled.
|
||||||
scheduledSystemPods, currentlyNotScheduledSystemPods := getSystemPods(c)
|
allScheduledPods, allNotScheduledPods := getFilteredPods(c, masterNodes, metav1.NamespaceAll)
|
||||||
systemPods := scheduledSystemPods + currentlyNotScheduledSystemPods
|
for len(allNotScheduledPods) != 0 {
|
||||||
|
|
||||||
// Wait for system pods to be scheduled, and for pods in all other namespaces to be deleted
|
|
||||||
for currentlyNotScheduledSystemPods != 0 || systemPods != allPods {
|
|
||||||
time.Sleep(2 * time.Second)
|
time.Sleep(2 * time.Second)
|
||||||
|
|
||||||
scheduledSystemPods, currentlyNotScheduledSystemPods := getSystemPods(c)
|
|
||||||
systemPods = scheduledSystemPods + currentlyNotScheduledSystemPods
|
|
||||||
allPods = getAllPods(c)
|
|
||||||
|
|
||||||
if startTime.Add(timeout).Before(time.Now()) {
|
if startTime.Add(timeout).Before(time.Now()) {
|
||||||
|
framework.Logf("Timed out waiting for the following pods to schedule")
|
||||||
|
for _, p := range allNotScheduledPods {
|
||||||
|
framework.Logf("%v/%v", p.Namespace, p.Name)
|
||||||
|
}
|
||||||
framework.Failf("Timed out after %v waiting for stable cluster.", timeout)
|
framework.Failf("Timed out after %v waiting for stable cluster.", timeout)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
allScheduledPods, allNotScheduledPods = getFilteredPods(c, masterNodes, metav1.NamespaceAll)
|
||||||
}
|
}
|
||||||
return scheduledSystemPods
|
return len(allScheduledPods)
|
||||||
}
|
}
|
||||||
|
|
||||||
// getAllPods lists all pods in the cluster, with succeeded and failed pods filtered out and returns the count
|
// getFilteredPods lists scheduled and not scheduled pods in the given namespace, with succeeded and failed pods filtered out.
|
||||||
func getAllPods(c clientset.Interface) int {
|
func getFilteredPods(c clientset.Interface, masterNodes sets.String, ns string) (scheduledPods, notScheduledPods []v1.Pod) {
|
||||||
allPods, err := c.CoreV1().Pods(metav1.NamespaceAll).List(metav1.ListOptions{})
|
pods, err := c.CoreV1().Pods(ns).List(metav1.ListOptions{})
|
||||||
framework.ExpectNoError(err, "listing all pods in kube-system namespace while waiting for stable cluster")
|
framework.ExpectNoError(err, "listing all pods in kube-system namespace while waiting for stable cluster")
|
||||||
// API server returns also Pods that succeeded. We need to filter them out.
|
// API server returns also Pods that succeeded. We need to filter them out.
|
||||||
currentPods := make([]v1.Pod, 0, len(allPods.Items))
|
filteredPods := make([]v1.Pod, 0, len(pods.Items))
|
||||||
for _, pod := range allPods.Items {
|
for _, pod := range pods.Items {
|
||||||
if pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
|
if pod.Status.Phase != v1.PodSucceeded && pod.Status.Phase != v1.PodFailed {
|
||||||
currentPods = append(currentPods, pod)
|
filteredPods = append(filteredPods, pod)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
allPods.Items = currentPods
|
pods.Items = filteredPods
|
||||||
return len(allPods.Items)
|
return e2epod.GetPodsScheduled(masterNodes, pods)
|
||||||
}
|
|
||||||
|
|
||||||
// getSystemPods lists the pods in the kube-system namespace and returns the number of scheduled and unscheduled pods
|
|
||||||
func getSystemPods(c clientset.Interface) (int, int) {
|
|
||||||
systemPods, err := c.CoreV1().Pods(metav1.NamespaceSystem).List(metav1.ListOptions{})
|
|
||||||
framework.ExpectNoError(err, "listing all pods in kube-system namespace while waiting for stable cluster")
|
|
||||||
scheduledSystemPods, currentlyNotScheduledSystemPods := e2epod.GetPodsScheduled(masterNodes, systemPods)
|
|
||||||
return len(scheduledSystemPods), len(currentlyNotScheduledSystemPods)
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user