Repository navigation
fix(mpi): EFA-capable security group, unmangled --mpi-command, count-aware estimate - #681
Merged
Merged
Conversation
…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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
CreateOrGetMPISecurityGroupauthorized onlytcp0-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 atMPI_Win_createrather 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 existingEnsureLustrePortspattern.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-commandonly worked without argumentsshellEscapeissecurity.ShellEscapeisstrconv.Quote, which wraps the whole string in one pair of double quotes. So--mpi-command "./gchp --flag x"reachedmpirunas a single argv word and it tried to exec a binary of that literal name.And as you noted,
strconv.Quoteis 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-commandexpects. It is now written to/etc/spawn/mpi-commandthrough a single-quoted here-doc (nothing expands while writing, so the text lands byte-exact) and executed withmpirun … bash /etc/spawn/mpi-command.#662 —
--estimate-onlyignored--countQuoted $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
--countof 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:
security.ShellQuote— real single-quoting,'\''for an embedded quote — with tests for$HOME,$(id), spaces and quotes.ShellEscape's doc comment, which claimed it "handles all special shell characters". It is now marked deprecated and says what it actually does.pkg/launcher's local copy (added in --command still runs BEFORE the storage mounts (EFS/FSx/volumes): #166 fixed --user-data but not --command #668) at the shared primitive.spawn config set, where a value containing$(…)executes on the instance instead of being stored — self-inflicted, since the caller already owns the box, but still wrong. Two places in the tree had already worked aroundShellEscapewith their own quoting and comments explaining why, which is how the pattern surfaced.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
ingress = [tcp],egress = []before the fix.GetDefaultVPC. The emulator serves no default VPC, so my first version skipped all three — a green run proving nothing, which is the same trap I just removed from truffle (snapshot create: ext4 lost+found is root-only 0700 → noisyfindPermission denied on volume walks #177 there).mpiruninvokesbash. Two of these tests initially failed on my own comment text matching the assertion, so they now anchor onmpirun --mcaand parse the here-doc body rather than string-matching the whole script.countis forced back to 1.Gates clean locally before pushing:
gofmt -lempty,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, orosu_latencybetween 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.