Repository navigation
Description
Two bugs, both mine, both found by running spawn cleanup --dry-run against a real account while verifying #708. The first rests on a claim I made in #706 that was simply wrong.
1. I was wrong that RGT does not return placement groups
#706 added a dedicated DescribePlacementGroups scan on the premise that the Resource Groups Tagging API does not return placement groups. I wrote that in the PR, the commit message and the v0.121.0 changelog. It is false:
$ aws resourcegroupstaggingapi get-resources --tag-filters Key=spawn:managed,Values=true \
--query 'ResourceTagMappingList[?contains(ResourceARN,`placement-group`)].ResourceARN'
arn:aws:ec2:us-east-1:435415984226:placement-group/pg-040e64301b7f056f7
arn:aws:ec2:us-east-1:435415984226:placement-group/pg-0575969a098a7e9bd
arn:aws:ec2:us-east-1:435415984226:placement-group/pg-07c13dfd3828f43bfRGT returns them keyed by group ID. The probe I based the claim on returned empty, but the account had zero placement groups at the time — so it could not distinguish "unsupported type" from "none exist". I noted that ambiguity at the time and then asserted the strong version anyway. That is the actual error; the code was a reasonable response to a premise I should not have adopted.
Consequence 1a: everything reported twice
us-east-1 ec2 placement-group pg-040e64301b7f056f7 - -
us-east-1 ec2 placement-group pg-0575969a098a7e9bd - -
us-east-1 ec2 placement-group pg-07c13dfd3828f43bf - -
us-east-1 ec2 placement-group spawn-mpi-smoke22812-us-east-1a empty -
us-east-1 ec2 placement-group spawn-mpi-smoke85337-us-east-1a empty -
us-east-1 ec2 placement-group spawn-mpi-smoke87201-us-east-1a empty -
Six rows, three groups. The pg-… rows come from RGT with no state; the named ones from the dedicated scan with one.
Consequence 1b: the id-keyed row cannot be deleted, and the failure is swallowed
RemoveResource routes placement-group to DeletePlacementGroupWithRetry(ctx, r.ID, …). EC2's DeletePlacementGroup takes a GroupName, not an id, so pg-040e… fails with InvalidPlacementGroup.Unknown — which the ignoreNotFound(…, "InvalidPlacementGroup.Unknown") I added then treats as success. Cleanup reports removing a group it never touched.
That is worse than the double-report: a tolerant error check turned a real failure into a clean bill of health.
Fix: drop RGT's placement-group rows and keep the dedicated scan, which supplies the two things RGT does not — the name (needed to delete) and whether the group still has members (needed to call it an orphan). Dropping is narrowly scoped to that one type, with a test asserting no other type is suppressed, since hiding a type with no replacement scan would be #708 again.
2. Fixing #708 unmasked an over-eager IAM classification
IsLikelyOrphan's only signal for IAM is !hasRunningInstance. That says nothing about whether spored-instance-role and spored-instance-profile are wanted — they are created once and reused by every launch. So in an idle account they are orphans, and a dry run offered both:
us-east-1 iam instance-profile spored-instance-profile - -
us-east-1 iam instance-profile spored-instance-role - -
spawn cleanup --yes would delete spawn's own shared identity.
This was latent, not new. The --mine scope filtered on spawn:iam-user, a tag these never carry, so they were invisible to cleanup by default and the classification never fired. One bug was hiding the other — the same fix that surfaced 27 genuine orphans also made these two deletable.
Fix: named constants for the two identities, excluded from both IsLikelyOrphan and cleanup's removable set, reported with the reason instead. Per-run spawn-instance-<hash> profiles must stay reclaimable — there are 12 in the dev account, the oldest from 2026-07-19 — so there is a test for that direction too.
Verified on live data
| before | after | |
|---|---|---|
| placement-group rows | 6 (3 real) | 3 |
| total orphans | 27 | 25 |
Both gates confirmed to fail when the fix is reverted.
Note on v0.121.0
v0.121.0 shipped with the false RGT claim in its changelog and with both bugs. The double-report is cosmetic-plus-misleading; 1b means a cleanup in that version can claim to have deleted a placement group it did not. Worth a correction note in the next release's changelog rather than a rewritten tag.
Activity
fix(smoke): clean up the MPI security group and placement group (#713)
fix(cleanup): make --mine mean "not someone else's", and correct two …
fix(smoke): the leak check filtered on a name that never matched (#713)
chore(release): v0.122.0