Repository navigation
fix: --mpi-command honours a custom --completion-file (#1170) - #1184
Merged
Merged
Conversation
The MPI script wrote every completion record, on rank 0 and over ssh on each peer, to a hardcoded /tmp/SPAWN_COMPLETE while spored watched the --completion-file path, so with a custom path no member fired --on-complete and the cohort billed to TTL. MPIConfig.CompletionFile now carries the path; every write renders it shell-quoted (twice for the peer's remote shell, with the record piped on stdin) after a mkdir of its directory. The default is unchanged. Fixes #1170
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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.
Summary
--mpi-commandignored a custom--completion-file. spored watches the path in--completion-file(LaunchConfig.CompletionFile, carried byspawn:completion-file). The MPI script inpkg/userdata/mpi.gowrote all four of its completion records to a hardcoded/tmp/SPAWN_COMPLETE:spawn_mpi_done's local record on rank 0,spawn_mpi_done's ssh write to each peer,--mpi-command).With any other path, no member fired
--on-complete, and the whole cohort billed until its TTL. This is the MPI twin of #1131 (fixed for--commandin #1164). The fix uses the same approach.MPIConfig.CompletionFileis new. The CLI passesinstanceConfig.CompletionFileinbuildJobArrayMemberConfig. Empty means/tmp/SPAWN_COMPLETE, so the default is unchanged.security.ShellQuoteand handed to the template already quoted, so the template never interpolates a raw path.mkdir -p "$(dirname -- <path>)" || truefirst. Without it, a custom path in a directory that doesn't exist yet would fail the write underset -e, and the leak would come back.ssh -n … "$ip" "echo '$rec' > /tmp/SPAWN_COMPLETE". It is nowprintf '%s\n' "$rec" | ssh … "$ip" <cmd>.<cmd>is the fixed commandmkdir -p "$(dirname -- 'P')" || true; cat > 'P', quoted once for the peer's shell and once more for rank 0's. The record now goes over stdin, so neither shell parses it again.-nis dropped because stdin is now the record.Gates (each watched failing against a revert that compiles)
pkg/userdata/mpi_completion_file_test.go:echo <record> > <target>, where the record is a literal record with"source": "mpi"or$rec, quoted either way. It also finds every ssh hand-off of$rec, with continuation lines joined first. It fails if it finds no write./tmp/spawn out/it's $HOME/done, there must be exactly 2 local writes plus 1 peer write with--mpi-command, and 2 plus 0 without. Every local target must be exactlyShellQuote(path)./tmp/SPAWN_COMPLETEmust appear nowhere in the script. With no path set, the default is still'/tmp/SPAWN_COMPLETE'.bash -n. Every discovered local write is then run under bash and must land at exactly<tmp>/new dir/it's $HOME done. The peer write is run with a stubsshthat captures the remote command exactly as ssh would send it. That command is then run the way the peer's shell would run it (bash -c, record on stdin), and the record must land at the same path.runRank0Withruns rank 0's block with stub mpirun, ssh and hostname, and a custom path. Rank 0 and both peers must get the record at the custom path, and none at the default.cmd/launch_mpi_completion_file_test.go:buildJobArrayMemberConfigwithCompletionFile: /data/donemust write'/data/done'on members 0 and 1, and never/tmp/SPAWN_COMPLETE.Reverts tried. All compile (
go vetclean) and all fail:CompletionFile"echo '$rec' > /tmp/SPAWN_COMPLETE"ShellQuotedropped""TestMPIWaitsForPeerSSHBeforeMpirunnow expects the quoted> '/tmp/SPAWN_COMPLETE'.Checks
GOTOOLCHAIN=go1.26.9 make check: fmt, vet, check-goos, staticcheck, hermetic tests, nested modules and tidy all pass.check-build-tagsfails, but its output is identical to unmodifiedorigin/mainon this machine (diffed with the worktree path normalised; it's the/private/tmppath issue). So it's local-only.make check-docs: clean, no help text changed.semgrep scan --config=auto --error .: clean.pkg/userdatais not inapi/public-surface.txt, so there is nothing to regenerate.Not covered
--mpi-commandrender. I did not measure it against the largest real combined bootstrap, which shares the 16 KB user-data cap.Fixes #1170