diff --git a/internal/scheduler/constraints/constraints.go b/internal/scheduler/constraints/constraints.go index 569b93a204f..415ff2d888f 100644 --- a/internal/scheduler/constraints/constraints.go +++ b/internal/scheduler/constraints/constraints.go @@ -143,31 +143,27 @@ func (constraints *SchedulingConstraints) CheckConstraints( } // Global rate limiter check. - if sctx.Limiter != nil { - tokens := sctx.Limiter.TokensAt(sctx.Started) - if tokens <= 0 { - return false, GlobalRateLimitExceededUnschedulableReason, nil - } - if sctx.Limiter.Burst() < len(gctx.JobSchedulingContexts) { - return false, GangExceedsGlobalBurstSizeUnschedulableReason, nil - } - if tokens < float64(len(gctx.JobSchedulingContexts)) { - return false, GlobalRateLimitExceededByGangUnschedulableReason, nil - } + tokens := sctx.Limiter.TokensAt(sctx.Started) + if tokens <= 0 { + return false, GlobalRateLimitExceededUnschedulableReason, nil + } + if sctx.Limiter.Burst() < len(gctx.JobSchedulingContexts) { + return false, GangExceedsGlobalBurstSizeUnschedulableReason, nil + } + if tokens < float64(len(gctx.JobSchedulingContexts)) { + return false, GlobalRateLimitExceededByGangUnschedulableReason, nil } // Per-queue rate limiter check. - if qctx.Limiter != nil { - tokens := qctx.Limiter.TokensAt(sctx.Started) - if tokens <= 0 { - return false, QueueRateLimitExceededUnschedulableReason, nil - } - if qctx.Limiter.Burst() < len(gctx.JobSchedulingContexts) { - return false, GangExceedsQueueBurstSizeUnschedulableReason, nil - } - if tokens < float64(len(gctx.JobSchedulingContexts)) { - return false, QueueRateLimitExceededByGangUnschedulableReason, nil - } + tokens = qctx.Limiter.TokensAt(sctx.Started) + if tokens <= 0 { + return false, QueueRateLimitExceededUnschedulableReason, nil + } + if qctx.Limiter.Burst() < len(gctx.JobSchedulingContexts) { + return false, GangExceedsQueueBurstSizeUnschedulableReason, nil + } + if tokens < float64(len(gctx.JobSchedulingContexts)) { + return false, QueueRateLimitExceededByGangUnschedulableReason, nil } // PriorityClassSchedulingConstraintsByPriorityClassName check. diff --git a/internal/scheduler/gang_scheduler.go b/internal/scheduler/gang_scheduler.go index bcd30e889b8..aba16014f33 100644 --- a/internal/scheduler/gang_scheduler.go +++ b/internal/scheduler/gang_scheduler.go @@ -60,11 +60,8 @@ func (sch *GangScheduler) Schedule(ctx context.Context, gctx *schedulercontext.G // Update rate-limiters to account for new successfully scheduled jobs. if ok && !gctx.AllJobsEvicted { - if sch.schedulingContext.Limiter != nil { - sch.schedulingContext.Limiter.ReserveN(sch.schedulingContext.Started, len(gctx.JobSchedulingContexts)) - } - qctx := sch.schedulingContext.QueueSchedulingContexts[gctx.Queue] - if qctx != nil && qctx.Limiter != nil { + sch.schedulingContext.Limiter.ReserveN(sch.schedulingContext.Started, len(gctx.JobSchedulingContexts)) + if qctx := sch.schedulingContext.QueueSchedulingContexts[gctx.Queue]; qctx != nil { qctx.Limiter.ReserveN(sch.schedulingContext.Started, len(gctx.JobSchedulingContexts)) } }