Repository navigation
fix(mpi): build the hostfile without jq; fail closed on any MPI setup failure (#1483) - #1485
Merged
Merged
Conversation
… failure (#1483) The MPI user data built its hostfile with jq, which stock AL2 lacks, so every AL2 member died there (127) and, with no completion record, the cohort billed to its TTL. Build it with awk from the peers file, and add an EXIT trap that writes a failed SPAWN_COMPLETE (source mpi-bootstrap) on any exit before a record, handing it to the peers from rank 0.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
Author
|
Live-verified on EC2 (2026-11-02) with a CLI built from
The first AL2 run failed on an unrelated race introduced by #1480: a peer's |
This was referenced Nov 2, 2026
Merged
Merged
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.
Fixes #1483
What
awkfrom the peers file, the JSON that spawn writes itself (provider.MarshalPeers). It takes each"ip"member in file order and works on the indented or the compact form. No dependency is added. Stock AL2 lacksjq, and the old line died with 127 on every AL2 member.{"status": "failed", "exit_code": <status>, "source": "mpi-bootstrap"}to the completion file. That covers install, EFA, key setup, the peers-file wait, the hostfile, the--mpi-commandfiles and the peer-SSH wait.--mpi-command, the record goes throughspawn_mpi_done, so every peer in the hostfile gets it too. Any other member writes its own.--mpi-commandthe--commandworkload writes its own.exit 1and the trap writes the record, so theirsourcechanges frommpitompi-bootstrap.mpinow means only mpirun's result.spawn_exit_guard, which it replaces as the EXIT trap./tmp/mpi-hostfileis removed at the start. An image of a rank-0 instance can carry the parent cohort's hostfile, and until ssh-keygen runs it also carries the parent's private key. Without the removal, an early failure could signal the parent cohort's members.The published bootstrap body does not change. The MPI user data grows by 289 to 449 gzipped bytes, depending on the member; numbers below.
Gates (each watched failing against a compiling revert)
TestMPIUserDataToolsExistOnEveryBaseparses every rendered shape (rank, command, install, EFA, gate, ppn) with mvdan/sh. It discovers every command, including those in script here-docs such as the rank wrapper, and drops builtins (fromcompgen) and the script's own functions. Each tool left must be a base tool of AL2/AL2023 or installed first.the MPI user data runs "jq", which is not a base tool....TestMPIToolScanFindsJqproves the scan sees the old line.TestMPIFailureWritesAFailedCompletionruns the whole rendered script in a sandbox. Paths are relocated, PATH holds only base tools plus stand-ins, and there is no jq. It forces each step to fail on rank 0 and rank 1 (install, peers file, hostfile, mpirun setup, key, peer readiness) and asserts a failed record with the step's exit code. When rank 0 fails after the hostfile, it also asserts the record reaches the peers.trap spawn_mpi_exit EXIT: all 11 cases fail (no SPAWN_COMPLETE after a failed MPI step).spawn_mpi_donerouting:rank0/mpirun setupfails (never signalled peer).TestMPISuccessWritesNoBootstrapRecordruns a healthy cohort with no jq on PATH and checks the hostfile, the gate and that no stray record is written.mpi-bootstraprecord, which is the fail-closed half covering the original bug.TestMPIUserDataOnAL2Containerruns the healthy cases and the hostfile and mpirun-setup failures inamazonlinux:2under bash 4.2.46, and asserts that bash version. It skips unless docker and the image are present locally; it never pulls.TestMPIHostfileReadsMarshalPeersis a contract test, not a revert gate. It ties the awk step toprovider.MarshalPeers, in indented, compact and empty form.runRank0tests (--mpi-command never signals completion, so --on-complete terminate never fires; and its output isn't where 'spawn array logs' looks #894/--mpi-command ignores a custom --completion-file, so --on-complete never fires (sibling of #1131) #1170) now run the whole script through the same sandbox instead of the rank-0 tail.Sizes (gzip, MPI user data alone)
--mpi-command, gate--mpi-commandThe inline (dev) bare bootstrap is 7393 gzipped, against a budget of 8448.
Not covered / follow-ups
--commandsubshell launches writes no record. I filed it as A bootstrap failure after spored starts but before --command launches writes no completion record; the instance bills to TTL #1484 with a local repro. It isn't fixed here because detecting "the command was not launched" needs a marker in the published body. The gap also precedes this MPI trap on MPI members.yum. That is fine on AL2023, where yum is dnf. On Ubuntu without--skip-mpi-installit fails, now closed, with a failed record.Live AL2 EC2 verification with a branch-built CLI is still to do.