Skip to content

fix(launch): stop dropping --security-group-ids and --subnet-id - #676

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/667-security-group-ids
Oct 4, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/667-security-group-ids

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

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 a LaunchConfig in exactly one place — cmd/launch_batchqueue.go:206 — so every ordinary launch silently got the VPC default security group. One-line copy, in buildLaunchConfig next to the other flag overrides.

The RunInstances builder was never at fault: pkg/aws/client.go:557/:573 already set netInterface.Groups correctly 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-id had the identical gap — also assigned only at launch_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-id mount had two independent causes.

The managed MPI group overwrote your groups anyway. ensureSecurityGroup (cmd/launch_single.go:1100) did config.SecurityGroupIDs = []string{sgID}, so under --mpi the 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 --mpi is 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 by len(...) == 0 so it cannot clobber, and I left it alone.

A gate, and three more dropped flags

TestLaunchFlagsAreWired parses 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 the Flags().*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 own vpcID, 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:

flag effect issue
--vpc no LaunchConfig field exists; launches in the default VPC #673
--cartesian wrong sweep run count — bills for a sweep of the wrong shape #674
--use-reservation vestigial since #216; on-demand instance at on-demand price #675

All three are allowlisted with their issue numbers, so the gate enforces from now on without hiding the debt. I did not fix them here: --vpc changes EFS/FSx subnet resolution and --cartesian is 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: sgIDs still 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 in launch_network_flags_test.go.

Verification

Both regression tests confirmed to fail against the old code first, reporting the real symptom — SecurityGroupIDs = [] and SubnetID = "", not a compile error.

Gates clean locally before pushing: gofmt -l empty, 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.

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

codecov Bot commented Oct 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_single.go 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit cb98a2e into main Oct 4, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/667-security-group-ids branch October 4, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--security-group-ids is silently dropped on spawn launch: instances always get the default SG (breaks --efs-id)

1 participant