Repository navigation
Description
Summary
On an Amazon Linux 2 --ami, every --mpi launch fails silently. The bootstrap dies before mpirun ever runs, and no completion record is written, so --on-complete never fires and both members sit until the TTL (or the idle timeout). spawn launch still reports success, because spored verifies fine.
The cause is that the MPI user data builds the hostfile with jq (pkg/userdata/mpi.go, jq -r ".[] | \"\(.ip) slots=$SLOTS\"" /etc/spawn/job-array-peers.json > /tmp/mpi-hostfile). jq is preinstalled on AL2023 but not on AL2, and nothing installs it: the MPI fragment only does yum install -y openmpi openmpi-devel. Under the bootstrap's set -e, exit 127 ends the script right after the peers-file wait.
This affects v0.154.0 and fix/1481-mpirun-root (PR #1482) the same way. The --allow-run-as-root fix for #1481 is correct, but it is unreachable on stock AL2 until this is fixed. The amazonlinux:2 container reproduction in #1481 ran mpirun directly, so it never went through this line.
Evidence (EC2, us-east-1, arm64 AL2 ami-04c8b521a97d3e2a4 from /aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-arm64-gp2, 2x c7g.medium, 2026-11-02)
Both members, with v0.154.0 and with the PR #1482 build (2463472), at /var/log/cloud-init-output.log:
/var/lib/cloud/instance/scripts/part-001: line 160: jq: command not found
cloud-init[1212]: util.py[WARNING]: Failed running /var/lib/cloud/instance/scripts/part-001 [127]
Afterwards there was no /tmp/mpi-hostfile content, no /run/spawn/mpi-ready, no /var/log/spawn-command.log, no /tmp/SPAWN_EXITCODE and no /tmp/SPAWN_COMPLETE (on the PR build, also no /etc/spawn/mpi-rank on either member). rpm -q jq gave package jq is not installed, and yum info jq showed 1.6 available from amzn2-core. The instances stayed running, with spawn:ttl-deadline 1h out.
After yum install -y jq and re-running the rest of part-001 from the SLOTS= line (with /etc/profile.d/mpi.sh sourced, as the script does):
- v0.154.0 hit the --mpi-command as root fails on AL2: Open MPI 4.0.1 ignores OMPI_ALLOW_RUN_AS_ROOT #1481 root refusal (
mpirun has detected an attempt to run as root) on Open MPI 4.0.1, andSPAWN_COMPLETEread{"status": "failed", "exit_code": 1, "source": "mpi"}on both members; - the PR fix(mpi): pass --allow-run-as-root so --mpi-command starts as root on Open MPI 4.0.1 (AL2) #1482 build ran
rank-0/rank-1and wrote{"status": "completed", "exit_code": 0, "source": "mpi"}on both members.
So jq is the only blocker left on AL2 once #1482 is in.
Cost angle
The failure point sits after the peers-file wait, which has its own bounded failure path that writes SPAWN_COMPLETE, but before the peer-SSH wait, which also has one. The jq line has none. So an AL2 MPI cohort is not torn down by --on-complete and bills until the TTL or idle timeout.
Possible fixes
- Install
jqalongside openmpi in the MPI fragment (command -v jq || yum install -y jq), or - drop the
jqdependency: the peers file is spawn's own fixed-format JSON (seepkg/provider/peers_file.go), soawk/sed, or a tinysporedsubcommand, could emit the hostfile; - either way, a failure to build the hostfile should write a failed SPAWN_COMPLETE, like the neighbouring waits do, so
--on-completestill fires.
Activity
fix(mpi): build the hostfile without jq; fail closed on any MPI setup…
fix(mpi): build the hostfile without jq; fail closed on any MPI setup…