From a0274318ca924dbcd1ce3ac33abe65bb7f9ddf6c Mon Sep 17 00:00:00 2001 From: Trey Guckian <24757349+tgucks@users.noreply.github.com> Date: Mon, 20 Jul 2026 15:04:35 -0500 Subject: [PATCH] Swap fair share and urgency scheduling Signed-off-by: Trey Guckian <24757349+tgucks@users.noreply.github.com> --- internal/scheduler/nodedb/nodedb.go | 26 +++++++++---------- internal/scheduler/nodedb/nodedb_test.go | 5 ---- .../preempting_queue_scheduler_test.go | 2 +- 3 files changed, 14 insertions(+), 19 deletions(-) diff --git a/internal/scheduler/nodedb/nodedb.go b/internal/scheduler/nodedb/nodedb.go index be573f7e270..0a848ca0725 100644 --- a/internal/scheduler/nodedb/nodedb.go +++ b/internal/scheduler/nodedb/nodedb.go @@ -641,35 +641,35 @@ func (nodeDb *NodeDb) selectNodeForJobWithTxnAtPriority( pctx.NodeId = "" pctx.PreemptedAtPriority = internaltypes.MinPriority - // Schedule by preventing evicted jobs from being re-scheduled. - // This method respect fairness by preventing from re-scheduling jobs that appear as far back in the total order as possible. - if !nodeDb.disableFairshareScheduling { - if node, err := nodeDb.selectNodeForJobWithFairPreemption(txn, jctx); err != nil { + // Schedule by kicking off jobs currently bound to a node. + // This method does not respect fairness when choosing on which node to schedule the job. + if !nodeDb.disableUrgencyScheduling { + if node, err := nodeDb.selectNodeForJobWithUrgencyPreemption(txn, jctx, matchingNodeTypeIds); err != nil { return nil, err } else if err := assertPodSchedulingContextNode(pctx, node); err != nil { return nil, err } else if node != nil { - pctx.SchedulingMethod = context.ScheduledWithFairSharePreemption + pctx.SchedulingMethod = context.ScheduledWithUrgencyBasedPreemption return node, nil } } - pctx.NodeId = "" - pctx.PreemptedAtPriority = internaltypes.MinPriority - - // Schedule by kicking off jobs currently bound to a node. - // This method does not respect fairness when choosing on which node to schedule the job. - if !nodeDb.disableUrgencyScheduling { - if node, err := nodeDb.selectNodeForJobWithUrgencyPreemption(txn, jctx, matchingNodeTypeIds); err != nil { + // Schedule by preventing evicted jobs from being re-scheduled. + // This method respect fairness by preventing from re-scheduling jobs that appear as far back in the total order as possible. + if !nodeDb.disableFairshareScheduling { + if node, err := nodeDb.selectNodeForJobWithFairPreemption(txn, jctx); err != nil { return nil, err } else if err := assertPodSchedulingContextNode(pctx, node); err != nil { return nil, err } else if node != nil { - pctx.SchedulingMethod = context.ScheduledWithUrgencyBasedPreemption + pctx.SchedulingMethod = context.ScheduledWithFairSharePreemption return node, nil } } + pctx.NodeId = "" + pctx.PreemptedAtPriority = internaltypes.MinPriority + return nil, nil } diff --git a/internal/scheduler/nodedb/nodedb_test.go b/internal/scheduler/nodedb/nodedb_test.go index 627dc073426..cc8878814fa 100644 --- a/internal/scheduler/nodedb/nodedb_test.go +++ b/internal/scheduler/nodedb/nodedb_test.go @@ -933,11 +933,6 @@ func TestPreemptionScheduling(t *testing.T) { disableUrgencyScheduling: true, expectSuccess: false, }, - "fair-share preemption by default": { - registerEvictedJobs: true, - expectSuccess: true, - expectedSchedulingMethod: context.ScheduledWithFairSharePreemption, - }, "falls through to urgency-based preemption when fair-share disabled": { registerEvictedJobs: true, disableFairshareScheduling: true, diff --git a/internal/scheduler/scheduling/preempting_queue_scheduler_test.go b/internal/scheduler/scheduling/preempting_queue_scheduler_test.go index ac2e139e7f1..84d6667100d 100644 --- a/internal/scheduler/scheduling/preempting_queue_scheduler_test.go +++ b/internal/scheduler/scheduling/preempting_queue_scheduler_test.go @@ -716,7 +716,7 @@ func TestPreemptingQueueScheduler(t *testing.T) { // Schedule jobs that requires preempting one job in the gang, // and assert that all jobs in the gang are preempted. JobsByQueue: map[string][]*jobdb.Job{ - "A": testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass1, 17), + "A": testfixtures.N1Cpu4GiJobs("A", testfixtures.PriorityClass0, 17), }, ExpectedScheduledIndices: map[string][]int{ "A": testfixtures.IntRange(0, 16),