diff --git a/internal/scheduler/jobiteration.go b/internal/scheduler/jobiteration.go index e914988e4a3..f6733c26e39 100644 --- a/internal/scheduler/jobiteration.go +++ b/internal/scheduler/jobiteration.go @@ -72,8 +72,8 @@ func (repo *InMemoryJobRepository) EnqueueMany(jctxs []*schedulercontext.JobSche // sortQueue sorts jobs in a specified queue by the order in which they should be scheduled. func (repo *InMemoryJobRepository) sortQueue(queue string) { - slices.SortFunc(repo.jctxsByQueue[queue], func(a, b *schedulercontext.JobSchedulingContext) bool { - return a.Job.SchedulingOrderCompare(b.Job) == -1 + slices.SortFunc(repo.jctxsByQueue[queue], func(a, b *schedulercontext.JobSchedulingContext) int { + return a.Job.SchedulingOrderCompare(b.Job) }) } diff --git a/internal/scheduler/preempting_queue_scheduler_test.go b/internal/scheduler/preempting_queue_scheduler_test.go index ea9650c66f9..9b4d622d7e2 100644 --- a/internal/scheduler/preempting_queue_scheduler_test.go +++ b/internal/scheduler/preempting_queue_scheduler_test.go @@ -2022,8 +2022,14 @@ func TestPreemptingQueueScheduler(t *testing.T) { // which jobs are preempted). slices.SortFunc( result.ScheduledJobs, - func(a, b *schedulercontext.JobSchedulingContext) bool { - return a.Job.GetSubmitTime().Before(b.Job.GetSubmitTime()) + func(a, b *schedulercontext.JobSchedulingContext) int { + if a.Job.GetSubmitTime().Before(b.Job.GetSubmitTime()) { + return -1 + } else if b.Job.GetSubmitTime().Before(a.Job.GetSubmitTime()) { + return 1 + } else { + return 0 + } }, ) var scheduledJobs []*jobdb.Job