Introduce per queue time limit for scheduling new jobs#4710
Merged
JamesMurkin merged 18 commits intomasterfrom Feb 27, 2026
Merged
Introduce per queue time limit for scheduling new jobs#4710JamesMurkin merged 18 commits intomasterfrom
JamesMurkin merged 18 commits intomasterfrom
Conversation
The CandidateGangIterator assumes that iterators it was passed were ordered - Evicted jobs - Non-evicted jobs So if it ever saw a non-evicted job, it could them just drop the whole queue when `OnlyYieldEvicted` was true However in market based scheduling, that assumption does not hold true and you can get evicted and non-evicted jobs in a mixed ordering This meant if we ever hit something that caused `OnlyYieldEvicted` when using market based scheduling, you could end up preempting many (or all) evicted jobs, depending on the job ordering - as the CandidateGangIterator stopped considering the queue as soon as it saw a non-evicted job Now I've pushed that logic down through the iterator stack - as they are better placed to make the right assumptions - I've also removed the logic about OnlyYieldEvicted dotted all over CandidateGangIterator and it is now contained to their OnlyYieldEvicted/OnlyYieldEvictedForQueue functions Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
We have an existing configuration `NewJobsSchedulingTimeout` which limits how long the scheduler will allow for new job scheduling before it stops allowing new jobs to be scheduled that round
That works well - however what often happens is when the scheduler is slow, it is slow for a single queue
This PR therefore adds the same limit but per queue:
- This limits impact to a single queue
- This means the config can be set to a more aggressive value, as it only impacts a single queue when hit
This PR also:
- Updates how `NewJobsSchedulingTimeout` works to act like other constraints (adding logic to constraints.go)
- Updates where scheduling duration config lives
- Move MaxSchedulingDuration -> Scheduling.MaxSchedulingDuration
- Move NewJobsSchedulingTimeout -> Scheduling.MaxNewJobSchedulingDuration
- The motivation here is:
- More consistent naming
- Scheduling config moved to scheduling section of config
- For now this will be backwards compatible with warning
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com> # Conflicts: # internal/scheduler/scheduling/queue_scheduler.go
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
dejanzele
reviewed
Feb 26, 2026
| c := sl.Current().Interface().(SchedulingConfig) | ||
|
|
||
| // Validate scheduling timeouts | ||
| if c.MaxNewJobSchedulingDuration > 0 && c.MaxNewJobSchedulingDuration >= c.MaxSchedulingDuration { |
Member
There was a problem hiding this comment.
As we already use the https://github.com/go-playground/validator, can we use struct tags to validate like https://github.com/go-playground/validator/blob/master/_examples/struct-level/main.go#L47
Signed-off-by: JamesMurkin <jamesmurkin@hotmail.com>
MustafaI
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We have an existing configuration
NewJobsSchedulingTimeoutwhich limits how long the scheduler will allow for new job scheduling before it stops allowing new jobs to be scheduled that roundThat works well - however what often happens is when the scheduler is slow, it is slow for a single queue
This PR therefore adds the same limit but per queue:
This PR also:
NewJobsSchedulingTimeoutworks to act like other constraints (adding logic to constraints.go)