From cc5ec714c1fc724879bc7fe7ff90e6b48514352a Mon Sep 17 00:00:00 2001 From: Jan Chaloupka Date: Thu, 20 Nov 2025 17:03:22 +0100 Subject: [PATCH] fix(SchedulerPreemption/Async): schedule all medium priority pods first so all low priority pods can be preempted If not all medium priority pods are allowed to preempt low priority pods first the high priority pods may occupy the low priority spot and disallow medium priority pods to preempt all low priority pods. Thus leaving some low priority pods without a DeletionTimestamp field set and failing the "Check all low priority pods to be about to preempted." check. --- test/e2e/scheduling/preemption.go | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/test/e2e/scheduling/preemption.go b/test/e2e/scheduling/preemption.go index 3a8222861a0..776d06b7870 100644 --- a/test/e2e/scheduling/preemption.go +++ b/test/e2e/scheduling/preemption.go @@ -375,7 +375,7 @@ var _ = SIGDescribe("SchedulerPreemption", framework.WithSerial(), func() { highPriorityPods := make([]*v1.Pod, 0, 5*nodeListLen) mediumPriorityPods := make([]*v1.Pod, 0, 10*nodeListLen) - ginkgo.By("Run high/medium priority pods that have same requirements as that of lower priority pod") + ginkgo.By("Run medium priority pods that have same requirements as that of lower priority pod") for i := range nodeList.Items { // Create medium priority pods first // to confirm the scheduler finally prioritize the high priority pods, ignoring the medium priority pods. @@ -393,19 +393,6 @@ var _ = SIGDescribe("SchedulerPreemption", framework.WithSerial(), func() { }) mediumPriorityPods = append(mediumPriorityPods, p) } - - for j := 0; j < 5; j++ { - p := createPausePod(ctx, f, pausePodConfig{ - Name: fmt.Sprintf("pod%d-%d-%v", i, j, highPriorityClassName), - PriorityClassName: highPriorityClassName, - Resources: &v1.ResourceRequirements{ - // Set the pod request to the low priority pod's resources - Requests: lowPriorityPods[0].Spec.Containers[0].Resources.Requests, - Limits: lowPriorityPods[0].Spec.Containers[0].Resources.Requests, - }, - }) - highPriorityPods = append(highPriorityPods, p) - } } // All low priority Pods should be the target of preemption. @@ -421,6 +408,22 @@ var _ = SIGDescribe("SchedulerPreemption", framework.WithSerial(), func() { })) } + ginkgo.By("Run high priority pods that have same requirements as that of lower priority pod") + for i := range nodeList.Items { + for j := 0; j < 5; j++ { + p := createPausePod(ctx, f, pausePodConfig{ + Name: fmt.Sprintf("pod%d-%d-%v", i, j, highPriorityClassName), + PriorityClassName: highPriorityClassName, + Resources: &v1.ResourceRequirements{ + // Set the pod request to the low priority pod's resources + Requests: lowPriorityPods[0].Spec.Containers[0].Resources.Requests, + Limits: lowPriorityPods[0].Spec.Containers[0].Resources.Requests, + }, + }) + highPriorityPods = append(highPriorityPods, p) + } + } + // All high priority Pods should be schedulable by removing the low priority Pods. ginkgo.By("Wait for high priority pods to be ready for the preemption.") for _, pod := range highPriorityPods {