Repository navigation
fix(mpi): rank 0 waits for every member's MPI setup, not just its SSH, before mpirun (#1486) - #1489
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Live-verified on EC2 (2026-11-02) with a CLI built from a local merge of #1489 (
The 3-node AL2 run caught #1486 live. Rank 0's SSH probe of rank 2 was accepted at 04:58:46, but rank 2's Ubuntu confirmed #1490, which is wider than filed: there's no Cost was about $0.05 for 24 instances. The leak check is clean, and I confirmed it independently. |
…, before mpirun (#1486) Rank 0's #752 gate tested only that each member accepted a BatchMode SSH login. The cluster key reaches a peer over SSM before the peer's own bootstrap writes /etc/spawn/mpi-rank, so mpirun could exec it on a peer that did not have it yet (exit 127; 0.9 s late on AL2 live). Every member now writes /etc/spawn/mpi-node-ready, holding the job array ID, as the last step of its MPI setup, and rank 0's probe greps for this cohort's ID over the same SSH login. The 600 s bound and the mpi-bootstrap failure record are unchanged. The sandbox now runs each peer's own rendered script at a chosen login and an mpirun stand-in that runs each rank's program on that member's files, so the race is reproduced by count, not time. Fixes #1486
e4132a9 to
fbc800b
Compare
Fixes #1486
The race
Rank 0's pre-mpirun gate (#752) tested only that each member accepted a BatchMode SSH login. Rank 0's cluster key reaches a peer's
authorized_keysover SSM from the control plane, independently of (and usually before) the peer's own bootstrap reachingcat > /etc/spawn/mpi-rank. So mpirun could exec the #1480 rank wrapper on a peer that had not written it yet:bash: /etc/spawn/mpi-rank: No such file or directory, exit 127, a failed job on a healthy cohort (0.9 s late on AL2 live, 0.14 s from it on AL2023).Design: one marker, written last, holding the cohort ID
/etc/spawn/mpi-node-readyas the last step of its MPI script outside the rank-0 block. That is after the install, EFA,mpi.sh, the key setup, the hostfile and the--mpi-commandfiles (mpi-command,mpi-rank). One marker covers everything a rank reads on that member, including orted from the install and anything a later change adds before it. I chose this overtest -fon each file because a per-file list has to be kept in sync by hand.grep -qxF <job array ID> /etc/spawn/mpi-node-ready, over the same BatchMode SSH, so it still proves sshd andauthorized_keystoo. It checks for the ID rather than doing a baretest -fbecause an image of a member carries its parent cohort's marker,mpi-rankandmpi-command, and the SSM key can arrive before this script'srm -fof the marker (or spored's ami create: per-instance spored/plugin state (plugins.json, job-array env, peer files) is still baked into images #1241 sweep) runs. The marker is also added toinstancestate.Paths, whichTestEveryWrittenStatePathIsCoveredrequires.exit 1, whichspawn_mpi_exitrecords asmpi-bootstrapon every reachable member (fix(mpi): build the hostfile without jq; fail closed on any MPI setup failure (#1483) #1485). The messages now readall peers ready after NsandN peer(s) not ready (no SSH, or MPI setup unfinished) after Ns.scripts/hardware-smoke.sh's echo was updated to match. It reads the seconds file, not the line.Gates
TestMPIRankZeroWaitsForEveryMemberToFinishItsMPISetupruns rank 0's whole rendered script in the sandbox. It counts logins and never measures time:hosts/<ip>/) at a chosen login. The peer accepts SSH from login 1, but its files appear only at login 3.mpi-rankfails with bash's own 127, as on EC2.completedrecord.mpi-rank, and the same run inamazonlinux:2(bash 4.2, real AL2 coreutils/awk/grep; skips without docker/image). All three ran here.TestMPINodeReadyMarkerFollowsEveryFileARankReadsworks from discovery, not a list. It takes the program on the renderedmpirunline (bash /etc/spawn/mpi-rank), then, transitively, each file that a here-doc body this script writes refers to and that the script also writes. Today that discovers{/etc/spawn/mpi-rank, /etc/spawn/mpi-command}. It requires each to be written before the marker, the marker to be followed only by the rank-0 block (which ends the script), and rank 0's probe to grep this cohort's ID in that file. It covers plain,--efaand--skip-mpi-install.Every existing sandbox test now also runs real peer scripts and real rank wrappers, and all of them pass.
Watched failing against compiling reverts (template-only edits,
go vetclean)"$PEER_IP" true: the race test fails on the peer withbash: …/hosts/10.0.0.3/etc/spawn/mpi-rank: No such file or directory, givesno hosts/10.0.0.3/tmp/rank-ran,probed 10.0.0.3 0 times, want 3, and afailedrecord (the live --mpi-command: rank 0 can start mpirun before a peer has written /etc/spawn/mpi-rank (exit 127); the SSH readiness gate doesn't cover it #1486 failure, reproduced).test -f(ignores the ID): the stale-marker subtest fails withprobed 10.0.0.3 1 times, want 3and the late peer's rank never ran.--mpi-commandfiles: the static test fails with/etc/spawn/mpi-rank … is written after /etc/spawn/mpi-node-ready, the same formpi-command, anda step follows … outside the rank-0 block ("mkdir -p /etc/spawn").Sizes
Measured with the live #1486 shape (job array ID
l1485-al2-20261101-e57d9546,--mpi-command, ready gate):--efa: 3961 → 4083 gzip.The published bootstrap body does not change.
Checks
make checkpassed (run from /private/tmp).make lint: 0 issues in all 10 modules.semgrep scan --config=auto --error .: 0 findings.go test ./pkg/userdata ./pkg/instancestate ./cmdpassed, including the AL2 container runs.Live check before merge (branch-built CLI)
--mpi-commandrun on stock AL2 (the --mpi-command: rank 0 can start mpirun before a peer has written /etc/spawn/mpi-rank (exit 127); the SSH readiness gate doesn't cover it #1486 repro) and on AL2023. Expectspawn: all peers ready after Nsin rank 0'scloud-init-output.log, and/etc/spawn/mpi-node-readyon every member holding the job array ID. On each peer, its mtime should be at or after itsmpi-rank, and rank 0's mpirun should start after the last peer's marker. Both members should endcompletedand terminate. Repeat a few times, since the race was intermittent; more peers or--efawiden the window.--mpi-commandwith a peer that cannot install) and confirm rank 0 fails closed at 600 s withnot ready (no SSH, or MPI setup unfinished)and anmpi-bootstraprecord on every member, then terminates.