fix(spur-cli): resolve first allocated node from compressed hostlist - #589
Draft
maybeharshit wants to merge 1 commit into
Draft
fix(spur-cli): resolve first allocated node from compressed hostlist#589maybeharshit wants to merge 1 commit into
maybeharshit wants to merge 1 commit into
Conversation
srun and sattach extracted the job's first node with `nodelist.split(',')`,
but the controller reports `JobInfo.nodelist` as a compressed Slurm-style
hostlist (e.g. `node[001-002]`). Splitting that on commas yields a bracket
fragment, so both tools targeted a non-existent host: sattach failed to
connect and srun silently skipped live output streaming.
Add `spur_core::hostlist::expand_first`, which expands a pattern only far
enough to yield its first hostname (the inverse of the controller's
`compress`), and a shared `nodelist::first_allocated_node` helper that both
call sites now use. Falls back to a comma-split for malformed patterns.
Co-authored-by: Cursor <cursoragent@cursor.com>
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.
What
srunandsattachconnect directly to a job's first allocated node to streamlive output. They extracted that node from
JobInfo.nodelistwithnodelist.split(',').next()— but the controller reportsnodelistas acompressed Slurm-style hostlist (built by
spur_core::hostlist::compress),not a raw comma list. For any job on 2+ nodes this yields a non-hostname:
node[001-002]has no top-level comma, so the split returns the whole literalnode[001-002].node[001,003]has a comma only inside the brackets, so the split returns thebroken fragment
node[001.gpu[001-004],cpu[001-002]) splits into the fragmentgpu[001-004.The result was used directly as a host:
sattachdialedhttp://node[001-002]:6818and failed to connect, andsrun'sget_node()probe failed so live output was silently skipped. Fixes #575.
Approach
spur_core::hostlist::expand_first, which expands a pattern only farenough to yield its first hostname — the inverse of the controller's
compress, and cheaper thanexpand(..).next()for large allocations.spur_cli::nodelist::first_allocated_nodehelper that both callsites now use, replacing the duplicated
split(',')logic. It falls back to acomma-split for a malformed pattern so a bad input still yields something
connectable rather than nothing (mirroring
expand_hostlist_or_split).sattach(clear error if unresolvable) andsruntry_stream_output(keeps the existing skip-on-failure behavior).The unrelated
srun::first_nodehelper (for user-typed-w, resolvedserver-side) is intentionally left unchanged.
Design choices
hardened
compress()and verifiedexpand(compress(x))round-trips, sorelying on
expand/expand_firstis guaranteed correct even for mixedzero-padding (
node[9,010-011]) and multi-prefix lists.no upgrade/compat hazard.
Testing
expand_firsttests (range, gap, multi-prefix, mixed padding, plainlist, single, empty, suffix bracket, unmatched-bracket error, and parity with
expand(..).next()), plusfirst_allocated_nodetests.cargo clippy(spur-core, spur-cli) clean;
cargo testfor spur-core and spur-cli pass.spurnode[1-2]:before the fix,
sattachfailed with a DNS error onspurnode[1-2]; after,sattachconnects tospurnode1and streams live output, andsrun -N2streams from both nodes with no controller-side connect errors.
Made with Cursor