Repository navigation
Windows launches: delete the per-instance security group with its instance (#1623) - #1636
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
scttfrdmn
force-pushed
the
hardening/1623-windows-sg-deleter
branch
from
November 14, 2026 20:17
a33bf41 to
f668b34
Compare
…tance (#1623) spawn terminate now reads a Windows instance's spawn:purpose=windows groups before terminating it, waits for terminated, and deletes them (retrying DependencyViolation while the ENI detaches; a group another live instance uses is left). Every other way an instance ends is covered by the TTL reaper, whose network-resource sweep now reclaims an unused per-instance Windows group after an hour instead of seven days.
scttfrdmn
marked this pull request as ready for review
November 14, 2026 23:15
scttfrdmn
force-pushed
the
hardening/1623-windows-sg-deleter
branch
from
November 14, 2026 23:15
f668b34 to
d8fa6e6
Compare
This was referenced Nov 15, 2026
Merged
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 #1623
What changes
spawn terminatedeletes the per-instance Windows group. For an instance taggedspawn:os=windows, terminate reads itsspawn:managed=true, spawn:purpose=windowsgroups before terminating (a terminated instance soon stops reporting them). After the terminate request it waits up to 10 min forterminated, then deletes each group, retryingDependencyViolationwhile the ENI detaches. A group another live instance still uses (two launches with one--namesharespawn-windows-<name>) is left and named. It is best-effort: the instance is already terminating, so a failure prints the reason and the manual command and never fails terminate. The deleter ispkg/awsInstanceWindowsSecurityGroups+DeleteSecurityGroupsAfterTerminate, the same wait-then-delete shape asegress-proxy delete.WindowsSecurityGroupPurposereplaces the"windows"literal at creation.spored's self-terminate path cannot do this. The instance is what dies, and its ENI detaches only after spored is gone. So that path, and the reaper's own terminate and a console terminate, rely on the TTL reaper. Its network-resource sweep already reclaimed spawn-managed groups with no instance (this confirms
spawn-windows-*is covered), but only after 7 days, a grace meant for the MPI group that later runs reuse by name. Aspawn:purpose=windowsgroup now gets 1 hour (perInstanceGroupGrace). An occupied one is never touched.Tests
pkg/aws/windows_sg_test.go: only the Windows group is selected (not MPI, not a user's group). Deletion happens after termination, with two DependencyViolation retries. A group shared withi-twinis left, with the error naming it. Nothing is deleted while the instance never reaches terminated. The reaper's literal must equalWindowsSecurityGroupPurpose.lambda/ttl-reaper/netresources_test.go: of four groups, only the 2-hour-old unused Windows group is deleted. A 20-minute-old one, an occupied one, and an MPI group (still 7 days) are kept.api/public-surface.txt(3 additions) anddocs/reference/cli-iam-actions.md:spawn terminatenow needsec2:DescribeSecurityGroupsandec2:DeleteSecurityGroup.make checkis clean apart from the known space-in-path failures. Semgrep is clean.Deploy steps
spawn-ttl-reaper: code-only (the reaper role already hasec2:DeleteSecurityGroup, tag-gated onspawn:managed=true). No IAM change. The sweep followsREAPER_NET_RESOURCES:reportlogsWOULD reap security group ... spawn-windows-...and deletes only underreap.Live checks for the owner
spawn launch --os windows --name sgtest --ttl 30m, thenspawn terminate sgtest --yes. It printsDeleted security group sg-..., andaws ec2 describe-security-groups --filters Name=group-name,Values=spawn-windows-sgtestis empty.aws ec2 terminate-instances(not spawn), wait more than an hour, and confirm the reaper's next run logsREAPED security group ... (spawn-windows-...)underreap, orWOULD reapunderreport. Then confirm the group is gone or delete it.spawn orphans).