Skip to content

fix(mpi): EFA-capable security group, unmangled --mpi-command, count-aware estimate - #681

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/659-660-662-efa-mpi
Oct 4, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/659-660-662-efa-mpi

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #659. Fixes #660. Fixes #662.

Priority 2 — the EFA/MPI correctness set. All three reproduced before fixing, and every new assertion confirmed to fail against the old code.

#659 — the MPI security group could not carry EFA traffic

CreateOrGetMPISecurityGroup authorized only tcp 0-65535 from itself. Your diagnosis of the consequence was the important part: this is not a slowdown. EFA's SRD is not TCP, so the fabric is blocked outright, and GCHP/MAPL aborts at MPI_Win_create rather than falling back — so the launch simply dies.

Rules are now self-referential and all-protocol (IpProtocol: "-1"), ingress and egress.

Egress is set explicitly even though a freshly created group already has a permissive default egress rule — which is precisely why this was never noticed. AWS documents EFA as requiring the self-referential egress rule, and anyone who tightens that default otherwise loses the fabric with no indication why.

The reuse case is the half that would otherwise have stranded every current user. The old code returned the found group the instant it matched the name, without looking at its rules. So every spawn-mpi-* group already in an account keeps only the old TCP rule, and upgrading spawn would have changed nothing — with no workaround short of deleting the group by hand, which fails while any instance still references it (InvalidPlacementGroup.InUse's cousin). The rule check now runs on every launch and treats a duplicate-rule error as success, following the existing EnsureLustrePorts pattern.

The other half of #659 — the managed group discarding --security-group-ids — was already fixed in #667, and I checked its tests still pass here. Nothing in this PR re-overwrites that.

#660 — --mpi-command only worked without arguments

shellEscape is security.ShellEscape is strconv.Quote, which wraps the whole string in one pair of double quotes. So --mpi-command "./gchp --flag x" reached mpirun as a single argv word and it tried to exec a binary of that literal name.

And as you noted, strconv.Quote is Go escaping inside double quotes, where $VAR, $(…) and backticks all still expand — so it preserved neither argv nor safety. It failed at both jobs simultaneously.

So the fix is not to escape harder. A command line is meant to be parsed by a shell at run time, which is what a user writing --mpi-command expects. It is now written to /etc/spawn/mpi-command through a single-quoted here-doc (nothing expands while writing, so the text lands byte-exact) and executed with mpirun … bash /etc/spawn/mpi-command.

#662 — --estimate-only ignored --count

Quoted $7.66/hr for a 2-node cohort whose real ceiling is $15.31. Above one instance the estimate now shows the per-instance rate and the total, for both the hourly figure and the TTL cost.

A --count of 1 prints byte-for-byte what it did before, so the common path gains no noise. A count of 0 or negative is clamped rather than multiplying the estimate to $0.00 — "free" is the most dangerous possible rendering of a cost bug.

Beyond the three issues

#660's root cause is a shared primitive, so I did not leave it pointed at the next caller:

I kept that audit out of this PR deliberately: migrating the storage templates changes generated user-data for every launch with a mount, and that deserves its own diff.

Verification

Gates clean locally before pushing: gofmt -l empty, go vet ./..., go test -short ./... (0 failures), make check-docs, changelog gate, semgrep scan --config=auto --error . → 0 findings.

Still no hardware verification, and #659 is the one that needs it most. The SG rule shape is testable; "EFA actually passes traffic" is not. Your tier-3 suggestion (fi_pingpong -p efa, or osu_latency between two nodes) remains the only real proof, and it needs two EFA-capable instances. Everything in this PR plus #678's barrier is now waiting on one 2-node run — worth doing together rather than piecemeal.

…aware estimate

#659: the auto-created MPI security group authorized only tcp 0-65535 from
itself. EFA's SRD is not TCP, so the fabric was blocked outright and
GCHP/MAPL aborts at MPI_Win_create rather than falling back. Rules are now
self-referential all-protocol ("-1"), ingress and egress, and existing
spawn-mpi-* groups are backfilled on reuse — previously the reuse path
returned a found group without inspecting its rules, so upgrading fixed
nothing for anyone who had already launched.

#660: --mpi-command went through shellEscape (strconv.Quote), which wrapped
the whole command in one pair of double quotes, so mpirun got a single argv
word. Only argument-free commands worked. It is now written to
/etc/spawn/mpi-command via a quoted here-doc and run with bash.

#662: --estimate-only ignored --count, quoting $7.66/hr for a 2-node cohort
whose real ceiling was $15.31.

Also adds security.ShellQuote (actual single-quote escaping) and corrects
ShellEscape's doc comment, which claimed to handle all special shell
characters. Remaining call sites audited in #680.

Fixes #659
Fixes #660
Fixes #662
@codecov

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 71.42857% with 16 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/securitygroup.go 58.62% 7 Missing and 5 partials ⚠️
cmd/launch_estimate.go 90.90% 1 Missing and 1 partial ⚠️
cmd/launch_single.go 0.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 8e28eb6 into main Oct 4, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/659-660-662-efa-mpi branch October 4, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant