Repository navigation
fix(sweep): honour CLI flags instead of dropping 83 of 127 (#697) - #724
Merged
Merged
Conversation
The sweep dispatch built a two-field LaunchConfig and buildLaunchConfigFromParams merged rows onto an EMPTY struct, so every other CLI flag was dropped by default. A flag worked only if someone had hand-written a shim, which is why the same class was reported and patched six times (#525, #539 twice, #549, #667, #673/#674/#675) — the architecture guaranteed there would be a seventh. Not cosmetic: a sweep could not mount ANY storage (--efs-id, all eleven --fsx-*, --attach-volume), every row landed in the VPC default security group even after #667 fixed single launches, and --pre-stop was dropped — the hook that syncs results before termination, so losing it loses output. The fix inverts the default. The dispatch now calls buildLaunchConfig, the same function the single-instance path uses, and each row merges onto that. "Honour every flag unless the row overrides it" instead of "drop everything unless someone wrote a shim". Row keys still win, preserving #539's precedence. Measured rather than asserted, using the coverage manifest: 84 flags honoured, up from 44; known gaps 58 -> 18. The two risks the issue flagged both turned out milder than feared, and I checked rather than assuming: - buildLaunchConfig's validations are mutual-exclusion guards that only fire when the user passed the relevant flags. Applying them to sweeps is strictly an improvement: --fsx-create without --fsx-s3-bucket was previously accepted-and-ignored. - The empty-field branches (firstConfig.KeyName == "", firstConfig.IamInstanceProfile == "") are FALLBACKS — "fill in if absent" — so populating a field just means the fallback runs less, which is the intent. One bug the inversion could easily have introduced, and a gate for it: `config := base` copies the struct, so without an explicit deep copy every row would share the base's Tags map, SecurityGroupIDs and AttachVolumes slices. One row adding a tag would add it to all of them, and rows launch CONCURRENTLY, so it would also be a race. Verified by removing the deep copy and watching the gate catch all four aliases including the leak back onto the base config. The 18 remaining gaps are a structurally different defect and the manifest now says so rather than lumping them together: --tag, --team, --spot-max-price, --fsx-throughput, --allow-cidr, --strata-* and the --wait-for-* pair are applied IMPERATIVELY later in launchSingleInstance, which the sweep dispatch returns before reaching. Nothing about them flows through a config, so the inversion could not have fixed them. Found by flipping all 58 to honoured and letting the gate name the ones that were still unreachable — which is the gate doing the classification instead of me guessing at it. Also widened the gate's notion of the sweep path to include launch_config.go, since the sweep now consumes its output. Before the inversion that would have been wrong.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… path The sweep leg is what the inversion needed: a sweep with --efs-id now actually attempts a mount on every row, which has never happened on this path before, and only an instance can tell you whether it works. It also found three things, two of them bugs in the leg itself: - --tag does not reach a sweep row (one of #697's 18 remaining gaps), so the first version filtered on a tag the rows never received and reported "found 0" while rows were running. The leg's own discovery key was a flag it exists to test the absence of. Rows are now found by the Name prefix spawn assigns. - `mount | grep -c` finishes in milliseconds, so the rows self-terminated before the SSM checks ran — the identical trap the storage leg documents ten lines above, which I wrote this leg without applying. The command now ends in `sleep 900`. - Cleanup and the leak check both needed the two-filter treatment, or the leg would leak its own rows while printing "no instances left behind" — the same false pass this check already produced once for placement groups. And the finding that matters, now scoped into the changelog rather than left implied: #697's fix covers the FOREGROUND path only. Detached is the DEFAULT (launchParameterSweep auto-enables it), and a detached sweep is launched by the spawn-sweep-orchestrator Lambda, which builds RunInstances from four param keys and never sees a LaunchConfig. On that path the drop is closer to 123 of 127 — and those rows get no UserData (no spored) and no spawn:managed tag (no reaper), so nothing can stop them. Filed as #725. Also seeded region/instance_type into paramFormat.Defaults from the CLI, because pkg/sweep/detached.go's cost estimator reads the param file directly and never sees a config: `--instance-type t4g.small` with rows that omit it still failed "param set 0: no instance_type specified". That is a seventh instance of this class and the first one a unit test could not have found, since the estimator only runs on a real launch.
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.
Closes #697. 84 flags now honoured, up from 44; known gaps 58 → 18 — measured by the coverage manifest, not asserted.
The inversion
The dispatch built a two-field
LaunchConfigandbuildLaunchConfigFromParamsmerged rows onto an empty struct, so every other CLI flag was dropped by default. A flag worked only if someone had hand-written a shim — which is why this class was reported and patched six times (#525, #539 twice, #549, #667, #673/#674/#675). The architecture guaranteed a seventh.The dispatch now calls
buildLaunchConfig— the same function the single-instance path uses — and each row merges onto that. Default inverts from "drop everything unless someone wrote a shim" to "honour every flag unless the row overrides it". Row keys still win, preserving #539's precedence.Both flagged risks were milder than feared, and I checked
buildLaunchConfig's validation applying to sweeps — all of its validations are mutual-exclusion guards that fire only when the user passed the relevant flags. Applying them to sweeps is strictly an improvement:--fsx-createwithout--fsx-s3-bucketwas previously accepted and ignored.The empty-field branches —
firstConfig.KeyName == ""andfirstConfig.IamInstanceProfile == ""are fallbacks ("fill in if absent"), not conditionals where empty means something else. Populating a field just means the fallback runs less, which is the intent.One bug the inversion could easily have introduced
config := basecopies the struct, so without an explicit deep copy every row would share the base'sTagsmap and itsSecurityGroupIDs/AttachVolumesslices. One row adding a tag would add it to all of them — and rows launch concurrently, so it would also be a data race.There's a gate for it, verified by removing the deep copy:
The 18 remaining gaps are a different defect
I found these by flipping all 58 gaps to honoured and letting the gate name the ones still unreachable — the gate doing the classification rather than me guessing. Twelve came back:
--tag,--team,--spot-max-price,--fsx-throughput,--fsx-skip-validate,--allow-cidr,--allow-cost-limit-overrun,--strata-*,--wait-for-running,--wait-for-sshAll are applied imperatively later in
launchSingleInstance(orlaunch_cost_limit.go/launch_batchqueue.go), which the sweep dispatch returns before reaching. Nothing about them flows through a config, so the inversion could not have fixed them. The manifest now records that distinction instead of lumping them in with the config-carried ones — it's a smaller and structurally different problem.I also widened the gate's notion of "the sweep path" to include
launch_config.go, since the sweep now consumes its output. Before the inversion, that would have been wrong.On the hardware smoke
make smoke-neededreports no hardware-sensitive paths changed — and I think it's under-inclusive here, so I'm flagging rather than relying on it.The config construction itself is pure data transformation and fully unit-tested. The risk is downstream: a sweep with
--efs-idwill now actually attempt an EFS mount on every row, which has never happened before. That makes previously-dead code paths live on the sweep path, and whether they work is a property of a running instance.So I'd like to run one before this ships: 2 rows, smallest viable instance, tight TTL, with
--efs-idto exercise exactly the newly-live storage path, leak-checked afterwards. That's a few cents. Not adding the sweep files to the manifest, because this is a one-time transition risk rather than a standing property of those files.Full suite green including
go test -tags e2e_tier0— the runner I missed on #722 and won't miss again.