Repository navigation
feat(mpi): install Open MPI with apt-get on Ubuntu AMIs (#1487) - #1492
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. |
The MPI user data installed Open MPI only with yum, so --mpi on an Ubuntu --ami without --skip-mpi-install died at 'yum: command not found'. - Detect the package manager with command -v: yum first (AL unchanged), then apt-get (openmpi-bin libopenmpi-dev, --no-install-recommends), retrying update+install up to 10x because DPkg::Lock::Timeout does not cover the apt lists lock; neither: fail closed naming --skip-mpi-install. - Read the instance ID from IMDSv2 when INSTANCE_ID is empty: Ubuntu has no ec2-metadata, so the key owner was empty and mpicohort never released rank 0's key. - mpi.sh: no empty LD_LIBRARY_PATH entry (cwd) when it was unset. - Tool inventory covers Ubuntu; package managers must be guarded. Fixes #1487
ff9a963 to
e646a0a
Compare
Fixes #1487
Based on main, not stacked on #1489. Both PRs touch
pkg/userdata/mpi.goandmpi_sandbox_test.go, so whichever merges second needs a rebase. The overlapping hunks are distinct: #1489 changes the readiness gate and the marker, this PR the install,mpi.shand the instance ID.Design
pkg/userdata/mpi.go): the package manager is detected withcommand -v.yumis tried first, so AL2 and AL2023 (dnf's yum alias) are byte-for-byte the same command.apt-get, which installsopenmpi-bin(mpirun and orted; it pulls inopenssh-client) andlibopenmpi-dev(mpicc and headers, likeopenmpi-devel) with--no-install-recommends. That is about 100 packages instead of 143, and drops gfortran. Ubuntu ships Open MPI 4.1.2 on 22.04 and 4.1.6 on 24.04; both are in fix(mpi): pass --allow-run-as-root so --mpi-command starts as root on Open MPI 4.0.1 (AL2) #1482's root matrix.apt-get updateand the install are retried together, up to 10 times 15 s apart. I measured inubuntu:24.04thatapt-get updateunder a held lists lock exits 100 immediately, with or without-o DPkg::Lock::Timeout, which waits only for the dpkg lock. On first boot, apt-daily or cloud-init can hold the lists lock. After 10 tries the script exits 1 and fix(mpi): build the hostfile without jq; fail closed on any MPI setup failure (#1483) #1485's trap recordsmpi-bootstrap.spawn: no yum or apt-get to install Open MPI; use an image with it and --skip-mpi-installand exits 1, which is recorded.TargetOS(windows/linux, from DescribeImages'Platform), and Windows already refuses--mpi. Ubuntu, Debian, SUSE and Alpine all reportPlatformas empty orLinux/UNIX. The SSH username (spawn:local-username) is decided on the instance by the bootstrap. A distro the install can't handle now fails closed within about 2 minutes, with that message, on every member.mpi.shon Ubuntu: nothing needed.mpirunandortedare in/usr/binand libmpi is in the default library path (checked in the container). The/usr/lib64/openmpientries don't exist there, which is harmless.LD_LIBRARY_PATH=/usr/lib64/openmpi/lib:$LD_LIBRARY_PATHended in an empty entry (the current directory) whenever the variable was unset, in every login shell on every MPI member, AL included. It is now${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}.ec2-metadata, and the bootstrap getsINSTANCE_IDonly from it. Ubuntu has noec2-metadata: it is absent from Canonical's 22.04 and 24.04 cloud-image manifests. So on Ubuntu, rank 0 would write an empty key owner file, andpkg/mpicohortreads rank 0's public key only once that file names the instance (ami create: an image of an MPI rank-0 instance carries the cohort's root SSH key, which a child cohort reuses #1338), so assembly could never complete. The fragment now reads the ID from IMDSv2 withcurl(already a base tool) whenINSTANCE_IDis empty. The bootstrap's own emptyINSTANCE_IDis filed as bootstrap: INSTANCE_ID is empty on Ubuntu (no ec2-metadata), so every tag read and the --command once-marker use an empty ID #1490, since fixing it changes the published bootstrap body.efa_installer.sh,mpi.shprepends/usr/lib64/openmpi/bin, and nothing puts/opt/amazon/openmpi/binon the script's PATH. The installer's profile.d snippet is read by login shells only. On Ubuntu that resolvesmpirunto/usr/bin/mpirun.ofiMTL and BTL, and its libfabric 1.17 is built with the efa provider./opt/amazon/openmpi. Not changed here, because switching needs EFA hardware to verify (orted prefix on the peers, ld.so order). Filed as --mpi --efa runs the distribution's Open MPI, not the EFA installer's /opt/amazon/openmpi #1491.Gates (
pkg/userdata/mpi_apt_test.go,mpi_tools_test.go)TestMPIInstallsOpenMPIWithApt: rank 0 of a 3-member cohort with no mpirun and onlyapt-get. Expect exactly an update then one install with-y openmpi-bin libopenmpi-dev, no yum, the correct hostfile, and acompletedrecord. Runs in the host sandbox and in anubuntu:24.04container (Ubuntu's bash 5.2, mawk, grep, coreutils; skips without docker or the image).TestMPIAptRetriesABusyLock:apt-get updatefails twice (counted), so expect 3 updates, 1 install, and success.TestMPIAptGivesUpAndFailsClosed: expect exactly 10 updates, then exit 1 with anmpi-bootstraprecord and no mpirun.TestMPINoPackageManagerFailsClosed: expect a recorded failure and a message naming--skip-mpi-install.TestMPIKeyOwnerIsTheInstanceWithoutEC2Metadata:INSTANCE_IDunset and a stub IMDS, so the key owner file must name the instance.TestMPIProfileAddsNoEmptyLibraryPathEntry: source the renderedmpi.shwithLD_LIBRARY_PATHunset; expect no empty entry.TestMPIUserDataToolsExistOnEveryBase), extended to Ubuntu:yumandec2-metadataare no longer base tools.yumandapt-getarempiPackageManagers, allowed only insideif command -v <same tool>; the AST is checked across the whole config matrix.TestMPIPackageManagerGuardScanSeesABareYumproves the scan sees the pre-MPI: add an apt install path for Ubuntu AMIs (today --mpi on Ubuntu can never work) #1487 bareyum.Watched failing against compiling reverts (template-only,
go vetclean)apt-getbranch: bothTestMPIInstallsOpenMPIWithAptruns (sandbox and ubuntu container) fail withrank 0 exited 1 on an apt-based member, and the retry and give-up tests fail.apt-get update+ install, no retry:rank 0 exited 100 although apt's lock was free on the third try, andapt-get update ran 1 times, want the bound of 10.ec2-metadata:key owner = "\n", want the instance's own ID from IMDS, and the tool gate reportsruns "ec2-metadata", which is not a base tool of every supported MPI base.yum install: the tool gate reportsruns "yum" outside 'if command -v yum', and the apt tests fail with exit 127 (the live Ubuntu failure).LD_LIBRARY_PATHline:mpi.sh sets LD_LIBRARY_PATH="/usr/lib64/openmpi/lib:", which has an empty entry.Real install, outside the test suite
In
ubuntu:24.04as root, with network, I ran the rendered rank-0 script against the realapt-getand real Open MPI 4.1.6, with a 1-host hostfile and 2 slots. The install succeeded andmpirunresolved to/usr/bin/mpirun. Through the rank wrapper with--allow-run-as-rootit printedrank-0andrank-1, the script exited 0, and it wrote{"status": "completed", "exit_code": 0, "source": "mpi"}.Sizes
MPI user data with the #1486 live shape (
--mpi-command, ready gate): 8487 → 9277 raw, 3765 → 4051 gzip (+286). With--efa: 3961 → 4242 gzip.Checks
make check(from /private/tmp),make lint(0 issues, 10 modules) andsemgrep scan --config=auto --error .(0 findings) all pass. The AL2 container tests pass too: bash 4.2, still on the yum path.Live check before merge (branch-built CLI)
--mpi --mpi-command 'echo rank-$OMPI_COMM_WORLD_RANK; hostname', no--skip-mpi-install. Expect incloud-init-output.log:Installing OpenMPI..., then the apt install (count any lock retries), thencommand -v mpirun→/usr/bin/mpirun./root/.ssh/spawn-mpi-key-owneron rank 0 must hold the instance ID. Also runcommand -v ec2-metadataon the AMI, which confirms bootstrap: INSTANCE_ID is empty on Ubuntu (no ec2-metadata), so every tag read and the --command once-marker use an empty ID #1490.completed/mpiand terminate. Check that root SSH between members works on Ubuntu's sshd (PermitRootLogin prohibit-passwordis expected to allow the key).--efaon Ubuntu (--mpi --efa runs the distribution's Open MPI, not the EFA installer's /opt/amazon/openmpi #1491). If tried, record whichmpirunran andfi_info -p efa.mpi-rank: No such file or directory, that is --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, not this PR.