Repository navigation
fix(launch): stop dropping --security-group-ids and --subnet-id - #676
Merged
Merged
Conversation
Both were parsed into package globals whose only assignment onto the LaunchConfig lived on the batch-queue path, so an ordinary `spawn launch --security-group-ids sg-...` exited 0 and used the VPC default group and an arbitrary subnet, silently. Also stop the managed MPI security group overwriting the caller's groups, which dropped the flag a second time under --mpi with no workaround. Adds TestLaunchFlagsAreWired, which found three more flags that are accepted and read by nothing: --vpc (#673), --cartesian (#674) and --use-reservation (#675). Fixes #667
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 #667. Your diagnosis was exact, and the file:line pointed straight at it.
The reported bug
sgIDs(cmd/launch_flags.go:239) was assigned onto aLaunchConfigin exactly one place —cmd/launch_batchqueue.go:206— so every ordinary launch silently got the VPC default security group. One-line copy, inbuildLaunchConfignext to the other flag overrides.The
RunInstancesbuilder was never at fault:pkg/aws/client.go:557/:573already setnetInterface.Groupscorrectly on both the EFA and non-EFA paths. The whole bug was upstream, which is where the regression test goes.Two things I found while in there
--subnet-idhad the identical gap — also assigned only atlaunch_batchqueue.go:208. Fixed in the same block, because it is the same bug and because it compounds the one you reported: the subnet picks the AZ, and a one-zone EFS mount target is only reachable from its own zone. So your hung--efs-idmount had two independent causes.The managed MPI group overwrote your groups anyway.
ensureSecurityGroup(cmd/launch_single.go:1100) didconfig.SecurityGroupIDs = []string{sgID}, so under--mpithe flag was dropped a second time even after reaching the config — and there was no flag-level workaround at all. It now merges, since an instance can carry 5 groups and--mpiis exactly when you need an extra one. This is the part of #659 that overlaps with this issue; the protocol rules (all-traffic ingress/egress for EFA SRD) are still #659's and untouched here. The Windows branch is already guarded bylen(...) == 0so it cannot clobber, and I left it alone.A gate, and three more dropped flags
TestLaunchFlagsAreWiredparses the package, finds every variable bound to a launch flag, and fails if nothing reads it. The compiler cannot catch this class: the variable is used, by theFlags().*Var()call that binds it.It skips any function that declares the name locally, and that rule is load-bearing — it is what exposed
--vpc. Every consumer has its ownvpcID, err := GetDefaultVPC(...)shadow, so a grep (or a naive AST identifier count) reads those as uses of the flag global and reports it as wired.Three flags are accepted today and read by nothing:
--vpcLaunchConfigfield exists; launches in the default VPC--cartesian--use-reservationAll three are allowlisted with their issue numbers, so the gate enforces from now on without hiding the debt. I did not fix them here:
--vpcchanges EFS/FSx subnet resolution and--cartesianis a feature, and neither belongs in a one-line-copy PR.Scope limit, stated plainly
This gate would not have caught #667. I checked by reverting the fix:
sgIDsstill has a reader (the batch-queue path), so it passes. Catching "read on one path but not the path that matters" needs call-path knowledge this cannot derive statically. The doc comment says so, so nobody mistakes its coverage later. #667 itself is covered by the ordinary regression tests inlaunch_network_flags_test.go.Verification
Both regression tests confirmed to fail against the old code first, reporting the real symptom —
SecurityGroupIDs = []andSubnetID = "", not a compile error.Gates clean locally before pushing:
gofmt -lempty,go vet ./...,go test -short ./...(57 packages, 0 failures),make check-docs, changelog gate,semgrep scan --config=auto --error .→ 0 findings.No hardware run. The fix is a field copy and the assertions are on the composed config, so there is nothing a real launch would prove that the unit tests do not — but the downstream claim (that an EFS mount now succeeds where it hung) is untested here, and that is the thing you actually hit. If you have a VPC with a non-default SG and an EFS mount target handy, that is the confirmation worth having.