From 9ab31affbe83588b1c5e261b86222b99e4bf2533 Mon Sep 17 00:00:00 2001 From: hasheddan Date: Fri, 26 Jun 2020 09:45:25 -0500 Subject: [PATCH] Do not ignore unscheduled pods when NodeName not in set of worker nodes When node scheduling tests were updated to use worker instead of master nodes the GetPodsScheduled function, which is tasked with getting all scheduled and not scheduled pods inadvertently was changed to ignore all pods that have an empty NodeName before checking whether pods had been scheduled or not. This updates the function to include pods without a NodeName in the check for unscheduled pods. Signed-off-by: hasheddan --- test/e2e/scheduling/predicates.go | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index 2d1bcbf556a..0155dc87845 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -1045,23 +1045,20 @@ func translateIPv4ToIPv6(ip string) string { // GetPodsScheduled returns a number of currently scheduled and not scheduled Pods on worker nodes. func GetPodsScheduled(workerNodes sets.String, pods *v1.PodList) (scheduledPods, notScheduledPods []v1.Pod) { for _, pod := range pods.Items { - if workerNodes.Has(pod.Spec.NodeName) { - if pod.Spec.NodeName != "" { - _, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled) - framework.ExpectEqual(scheduledCondition != nil, true) - if scheduledCondition != nil { - framework.ExpectEqual(scheduledCondition.Status, v1.ConditionTrue) - scheduledPods = append(scheduledPods, pod) - } - } else { - _, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled) - framework.ExpectEqual(scheduledCondition != nil, true) - if scheduledCondition != nil { - framework.ExpectEqual(scheduledCondition.Status, v1.ConditionFalse) - if scheduledCondition.Reason == "Unschedulable" { - - notScheduledPods = append(notScheduledPods, pod) - } + if pod.Spec.NodeName != "" && workerNodes.Has(pod.Spec.NodeName) { + _, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled) + framework.ExpectEqual(scheduledCondition != nil, true) + if scheduledCondition != nil { + framework.ExpectEqual(scheduledCondition.Status, v1.ConditionTrue) + scheduledPods = append(scheduledPods, pod) + } + } else { + _, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled) + framework.ExpectEqual(scheduledCondition != nil, true) + if scheduledCondition != nil { + framework.ExpectEqual(scheduledCondition.Status, v1.ConditionFalse) + if scheduledCondition.Reason == "Unschedulable" { + notScheduledPods = append(notScheduledPods, pod) } } }