Skip to content

Commit 9ab31af

Browse files
committed
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 <[email protected]>
1 parent a730ad5 commit 9ab31af

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

test/e2e/scheduling/predicates.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,23 +1045,20 @@ func translateIPv4ToIPv6(ip string) string {
10451045
// GetPodsScheduled returns a number of currently scheduled and not scheduled Pods on worker nodes.
10461046
func GetPodsScheduled(workerNodes sets.String, pods *v1.PodList) (scheduledPods, notScheduledPods []v1.Pod) {
10471047
for _, pod := range pods.Items {
1048-
if workerNodes.Has(pod.Spec.NodeName) {
1049-
if pod.Spec.NodeName != "" {
1050-
_, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
1051-
framework.ExpectEqual(scheduledCondition != nil, true)
1052-
if scheduledCondition != nil {
1053-
framework.ExpectEqual(scheduledCondition.Status, v1.ConditionTrue)
1054-
scheduledPods = append(scheduledPods, pod)
1055-
}
1056-
} else {
1057-
_, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
1058-
framework.ExpectEqual(scheduledCondition != nil, true)
1059-
if scheduledCondition != nil {
1060-
framework.ExpectEqual(scheduledCondition.Status, v1.ConditionFalse)
1061-
if scheduledCondition.Reason == "Unschedulable" {
1062-
1063-
notScheduledPods = append(notScheduledPods, pod)
1064-
}
1048+
if pod.Spec.NodeName != "" && workerNodes.Has(pod.Spec.NodeName) {
1049+
_, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
1050+
framework.ExpectEqual(scheduledCondition != nil, true)
1051+
if scheduledCondition != nil {
1052+
framework.ExpectEqual(scheduledCondition.Status, v1.ConditionTrue)
1053+
scheduledPods = append(scheduledPods, pod)
1054+
}
1055+
} else {
1056+
_, scheduledCondition := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
1057+
framework.ExpectEqual(scheduledCondition != nil, true)
1058+
if scheduledCondition != nil {
1059+
framework.ExpectEqual(scheduledCondition.Status, v1.ConditionFalse)
1060+
if scheduledCondition.Reason == "Unschedulable" {
1061+
notScheduledPods = append(notScheduledPods, pod)
10651062
}
10661063
}
10671064
}

0 commit comments

Comments
 (0)