Description
Summary
--mpi-command can fail on a peer with bash: /etc/spawn/mpi-rank: No such file or directory (exit 127). Rank 0's pre-mpirun gate (#752) only checks that each peer accepts SSH (ssh -o BatchMode=yes "$PEER_IP" true). It does not check that the peer has written /etc/spawn/mpi-rank. That file is the per-rank wrapper from #1479/#1480, and mpirun execs it on every rank. The cluster key reaches the peer's authorized_keys over SSM from the control plane, before the node is released. So SSH readiness comes earlier than, and independently of, the peer's own bootstrap reaching the cat > /etc/spawn/mpi-rank step. When rank 0 gets there first, mpirun execs a file that doesn't exist yet.
This race came in with #1480 (mpi-rank wrapper, unreleased, on main since 801f002). It is not caused by #1485 and was found while live-testing #1485 (#1483). Fail-closed handled it correctly: both members recorded failed/127 and terminated, so nothing leaked. But a healthy cluster fails at random.
Evidence (live, 942542972736 us-east-1, CLI built from fix/1483-mpi-jq-failclosed @ fed2b30, stock AL2 arm64 ami-04c8b521a97d3e2a4, 2x c7g.medium, --mpi-processes-per-node 1, --mpi-command 'echo rank-$OMPI_COMM_WORLD_RANK; hostname')
Run 1, l1485-al2-20261101-e57d9546 (i-02cb6ab8b14cdbcf9 rank 0, i-03f42851b9a961270 rank 1), FAILED:
# rank 0 /var/log/cloud-init-output.log
279:spawn: all peers accepted SSH after 0s
280:bash: /etc/spawn/mpi-rank: No such file or directory
285:rank-0
Process name: [[43081,1],1]
Exit code: 127
# both members: /tmp/SPAWN_COMPLETE
{"status": "failed", "exit_code": 127, "source": "mpi"}
File mtimes show the ordering:
rank 0 /etc/spawn/mpi-rank 03:15:15.893 (mpirun starts right after; peer gate passed "after 0s")
rank 1 /etc/spawn/mpi-rank 03:15:16.779 (~0.9 s later, after mpirun had already exec'd on it)
Run 2, the identical command (l1485-al2b-20261101-6d7f1d5a), PASSED. The peer won the race that time: rank 1 wrote mpi-rank at 03:21:35.186, before rank 0's 03:21:35.675.
AL2023 default AMI run (l1485-a23-20261101-87d1451d) PASSED with a 0.14 s margin: rank 0 wrote its hostfile at 03:21:47.576 and rank 1 wrote mpi-rank at 03:21:47.726.
So this is timing-dependent on every OS. It gets more likely with more peers, or with a slower peer such as a bigger yum transaction or EFA install.
Suggested fix
Make the #752 gate also check what mpirun is about to exec. For example, probe ssh ... "$PEER_IP" test -f /etc/spawn/mpi-rank (it is only rendered under {{if .MPICommand}}, and so is the mpirun call), or have each peer touch a readiness marker as the last step of its MPI fragment and probe for that. The existing bounded 600 s wait and the fail-closed exit stay as they are. A sandbox test should cover a peer whose mpi-rank appears after rank 0 reaches the gate.
Activity
fix(mpi): rank 0 waits for every member's MPI setup, not just its SSH…