Cancel newest queued Slurm workers when demand drops - #487
Merged
Conversation
When satisfiable demand falls below the tracked worker count, scancel
the excess jobs, newest-first. Only still-PENDING jobs are cancelled: a
running worker may hold a lease, and the idle timeout already retires
it once work runs dry.
PENDING-ness comes from the squeue call the pool already makes each
tick (%T added to the format). Unlike sacct, which reports queued array
tasks in one aggregate line ("100_[1-3]"), squeue --array lists them
individually, so no array-spec parsing is needed.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
hermabr
force-pushed
the
t3code/support-slurm-pool-scaling-1
branch
from
August 5, 2026 17:37
715f52a to
ed3be57
Compare
Owner
Author
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.
When satisfiable demand falls below the tracked worker count, the pool now scancels the excess, newest-first (older jobs have accrued queue age and are closest to being scheduled). Only still-PENDING jobs are cancelled: a running worker may hold a lease, and the idle timeout already retires it once work runs dry. Cancelled jobs are dropped from tracking immediately so their CANCELLED state can't be mistaken for the pool becoming unhealthy.
The one design choice worth noting: PENDING-ness is read from the squeue call the pool already makes every tick (
%Tadded to the format), not from sacct. sacct reports still-queued array tasks in one aggregate line (100_[1,2-4%2]), which would require parsing and expanding array-spec syntax in the pool; squeue--arraylists queued tasks individually, so array jobs need no special handling anywhere in production code._task_states(sacct) is untouched.Tests: the fake squeue now reports states and expands bracketed task specs the way real squeue does; new tests cover scale-down for plain jobs, scale-down for array jobs (aggregate bracket form in the fake), and that running workers are never cancelled.
🤖 Generated with Claude Code