Repository navigation
feat(reaper): reclaim orphaned security groups and placement groups (#685) - #727
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…685) The ordering and race bugs were fixed in v0.121.0 and discovery landed in `spawn orphans`/`cleanup`, but nothing reclaimed these without someone running a command: 19 security groups and 9 placement groups in one region of one account, the oldest three months old. Seven days with no instance referencing them, per the decision that nothing should be durable indefinitely. The grace is a policy choice: the MPI security group is keyed on spawn-mpi-<job-array-name> and reused BY NAME across runs (CreateOrGetMPISecurityGroup is a get-or-create, and #659 backfills rules onto an existing one), so a short grace would force a recreate on every repeat run of a named array. A week makes a weekly re-run free, and the recreate is cheap. Neither resource bills; the pressure is the per-VPC quota, which bites at launch time. Three deliberate conservatisms: - Membership is asked of EC2, not inferred from spawn's own instances, because ANY member blocks the delete — including one spawn did not create. Inferring would report a group empty and then fail to delete it. - A resource with no creation tag is SKIPPED, not assumed old. Neither describe call returns a creation time, so spawn's tag is the only source, and an untimed group could be seconds from use by a launch in flight. - DependencyViolation is tolerated rather than recorded as an error. A group can be referenced by another group's rule or an ENI, which the instance scan cannot see; alarming on it would fire every cycle. The IAM is simulated in BOTH directions rather than merely applied, because the spawn:managed=true DeleteSecurityGroup/DeletePlacementGroup allowed spawn:managed=false both implicitDeny no tag at all both implicitDeny DeleteVpc/DeleteSubnet/iam:DeleteRole implicitDeny Three gates caught things I would otherwise have shipped broken: - The reaper's policy had none of the four actions, so the sweep would have AccessDenied every cycle. - A bidirectional drift gate rejected the grants as unused, because its interface matcher was `^type ([a-z0-9]+)API` and my netResourceAPI has a capital. The gate was right that it could not see the calls; the matcher now allows camelCase. - A cross-role parity gate caught that only the scan-self policy had them, not the CloudFormation cross-account role — which is the PRODUCTION configuration, where a one-sided grant makes the feature silently no-op. Also found by hand: the cross-account account{} construction site uses acctCfg rather than base, so my regex missed it and the sweep would have skipped every assumed-role account while appearing to work on scan-self. netFor is wired at all three sites now. Deploying the reaper is a separate step and not done here.
scttfrdmn
force-pushed
the
fix/685-reap-net-resources
branch
from
October 8, 2026 01:56
27cc8ce to
5475c2b
Compare
This was referenced Oct 8, 2026
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 #685. The 7-day grace per your "I do not want anything long term durable".
What this closes
v0.121.0 fixed the ordering and race bugs and added discovery to
spawn orphans/cleanup, but nothing reclaimed these without someone running a command — 19 security groups and 9 placement groups in one region of one account, the oldest three months old.Seven days with no instance referencing them. The grace is a policy choice, not a technical one: the MPI security group is keyed on
spawn-mpi-<job-array-name>and reused by name across runs, so a short grace would force a recreate on every repeat run of a named array. A week makes a weekly re-run free, and the recreate is cheap since #659 already backfills rules onto an existing group.Three deliberate conservatisms
Membership is asked of EC2, not inferred from spawn's own instances — any member blocks the delete, including one spawn didn't create. Inferring would report a group empty and then fail to delete it.
An untimed resource is skipped, not assumed old. Neither describe call returns a creation time, so spawn's tag is the only source — and an untimed group could be seconds from use by a launch in flight.
DependencyViolationis tolerated, not alarmed on. A group can be referenced by another group's rule or an ENI, which the instance scan can't see. Alarming would fire every cycle.IAM simulated in both directions
Because #652/#665 were policies IAM accepted and didn't authorize:
DeleteSecurityGroup/DeletePlacementGroupspawn:managed=truespawn:managed=falseDeleteVpc,DeleteSubnet,iam:DeleteRoleRun against the rendered policy with
simulate-custom-policy, so no deploy was needed to prove it.Three gates caught things I'd have shipped broken
AccessDeniedevery cycle.^type ([a-z0-9]+)APIand mynetResourceAPIhas a capital letter. The gate was right that it couldn't see the calls; the matcher now allows camelCase.And one I found by hand: the cross-account
account{}site usesacctCfgrather thanbase, so my regex missed it and the sweep would have skipped every assumed-role account while appearing to work on scan-self.netForis wired at all three sites now.Interaction with #725, worth knowing
This sweep keys on
spawn:managed, and detached sweep rows don't carry it — so it's inert for sweep instances until #726 lands. That's why I did #726 first.Not done here
Deploying the reaper. The code is tested and the IAM is simulated, but the last two reaper deploys each caused an incident, so that's a separate deliberate step.