Repository navigation
fix(mpi): pass --allow-run-as-root so --mpi-command starts as root on Open MPI 4.0.1 (AL2) - #1482
Conversation
… Open MPI 4.0.1 (AL2) (#1481)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Live verification on EC2 (2026-11-02), owner-approvedRun in account 942542972736, us-east-1, on 2× c7g.medium with
Caveat. On stock AL2, the MPI user data dies earlier, at Cost was under $0.05. All 6 instances terminated, and the 3 test SGs were deleted. The leak check is clean, and I confirmed it independently. |
Fixes #1481
Decision: keep root, pass
--allow-run-as-root(option a)mpirun runs as root by design, and switching to the default user is not safe:
--mpi-commandhelp says "Rank 0 runs mpirun as root";/root/.sshkey mint/strip, the owner file,pkg/mpicohort/assembler.goauthorizing rank 0's key in root'sauthorized_keys);spawn_mpi_done's per-peer completion write go over that root mesh./tmp/SPAWN_EXITCODE, the completion file,/var/log/spawn-command.logand/etc/spawn/*are all written as root.Moving to a default user would mean re-plumbing the key mesh, the completion channel and the file ownership the users' commands see, and the default user differs per AMI. No part of the design already works that way. So the fix makes root work on every supported Open MPI.
Matrix (containers, as root,
mpirun --mca orte_base_help_aggregate 0 --oversubscribe -np 2)OMPI_ALLOW_RUN_AS_ROOT*env--allow-run-as-rootPRTE_ALLOW_RUN_AS_ROOT*envamazonlinux:2, yumopenmpi)amazonlinux:2023)ubuntu:22.04,openmpi-bin)ubuntu:24.04)fedora:41, PRRTEprterun)No version printed a warning or deprecation for the flag. The flag is the only mechanism that works everywhere, so no runtime version detection is needed. The env vars stay in
/etc/profile.d/mpi.shfor a user's own mpirun. Not checked: the EFA installer's/opt/amazon/openmpibuilds (4.1.x / 5.x upstream, the same lines as above).Change
pkg/userdata/mpi.go: the rank-0 mpirun line (the only mpirun invocation, found by discovery) gains--allow-run-as-root. The rationale and matrix live in the Go comment, not the template../sim): raw 7487 → 7507 B, gzip -9 3317 → 3330 B. The bootstrap body is unchanged.Gates (each watched failing against a compiling revert that drops only the flag)
TestEveryMPIRunAllowsRoot(text, all platforms): every mpirun invocation, discovered in the rendered scripts (5 configs) and in cmd/ and pkg/ Go source, passes--allow-run-as-rootas an mpirun option before the per-rank program. Revert: 6 errors (5 rendered configs +pkg/userdata/mpi.go:458).TestRenderedMPIRunStartsAsRoot(real mpirun, root only, otherwise skipped): runsmpirun <the rendered options> -np 2with only the env the renderedmpi.shexports, and both ranks must run. Revert, inamazonlinux:2:exited 1 with 0 of 2 ranks run: mpirun has detected an attempt to run as root.TestMPIRunEndsAtTheRanksExitWithARealMPIRun(fix(mpi): an --mpi-command rank ends at its command's exit, not its stragglers' (#1479) #1480's test) now takes the rendered mpirun options and the rendered root env instead of hard-coding the flag under root, so it is a second real-mpirun gate. Revert, inamazonlinux:2: all 4 subtests fail,mpirun exited 1.amazonlinux:2(4.0.1),amazonlinux:2023(4.1.2),ubuntu:24.04(4.1.6) andfedora:41(5.0.5), and as non-root on macOS (Homebrew 5.0.11; the root test skips).--prefixand put/usr/binfirst on the ranks' PATH. On Ubuntu that hid the countingsleepstub, and the stragglers subtest failed withdrains polled 0 times. The test now passes argv[0] as the barempirun, the way the user data runs it.Checks
make checkOK,make lint0 issues (10 modules),semgrep scan --config=auto --error .clean, launcher/tasklaunch budget tests OK. No help text changed, so no docs-gen.For the live AL2 EC2 check (not yet done)
Launch a 2-member
--mpicohort on an AL2--amiwith a CLI built from this branch, e.g.--mpi-command 'echo rank-$OMPI_COMM_WORLD_RANK; hostname',--on-complete terminate, short TTL. Check:/var/log/spawn-command.loghasrank-0andrank-1and nodetected an attempt to run as root;/tmp/SPAWN_EXITCODE= 0 and SPAWN_COMPLETE{"status": "completed", ... "source": "mpi"}on BOTH members, so both terminate via on-complete. This proves the remote orted (started over ssh as root) accepts root too, which a single-host container can't show;mpirun --versionon the instance says 4.0.1, so the case under test really ran;