Repository navigation
fix(pool): give an undrained pool's IAM role a deleter (#1319) - #1350
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
spawn pool create now names a pool's worker role and instance profile spawn-instance-pool-<hash of the run id>, inside the per-task family pkg/instancerole (the TTL reaper and spawn cleanup --instance-roles) already deletes, so a pool nobody drains loses its role once no worker holds it and it has been unused for 24h. A pool role must also carry a spawn:pool-run-id tag that hashes to its name. Pre-rename spawn-pool-worker-<hash> roles are outside the reaper's grants; spawn cleanup --instance-roles sweeps those (exact shape and tag match only), and spawn pool drain removes both names.
scttfrdmn
force-pushed
the
fix/1319-pool-worker-roles
branch
from
October 27, 2026 02:05
7327e42 to
9353e9a
Compare
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 #1319
What
spawn pool drainwas the only deleter of a pool'sspawn-pool-worker-<hash>role and instance profile, so an undrained pool (crashed caller, a forgotten drain, an nf-spawn run-end hook that never fired) left them in the account indefinitely.Chosen fix: rename pool roles into the per-task family instead of widening the reaper's grants.
spawn pool createnow names the role/profilespawn-instance-pool-<16 hex of sha256(run id)>(instancerole.PoolWorkerRoleName; cmd/pool.go calls it, so the created name and the deleted name can't drift). It is insidespawn-instance-*, so the TTL reaper's existingREAPER_INSTANCE_ROLESsweep andspawn cleanup --instance-rolesremove it under Leave no trace: reap per-task spawn-instance-<hash> IAM roles and instance profiles once no instance uses them #1300's rule: taggedspawn:managed=true, no instance in any enabled region (pending through stopped) holding the profile, role and profile at least 24h old, role unused for 24h. A pool with a live worker always keeps its role.spawn-instance-pool-*role is also kept unless itsspawn:pool-run-idtag hashes to its name (KeepPoolUnmatched).role/spawn-instance-*,instance-profile/spawn-instance-*, plus thespawn:managedtag conditions) already cover the new name. Neither template is touched.spawn-pool-worker-<hash>roles (pools created before this release) are outside the reaper's grants. They are swept only byspawn cleanup --instance-roles(instancerole.SweepWith(..., Options{LegacyPoolWorkers: true})), under the same rule, and only for the exactspawn-pool-worker-<16 lowercase hex>shape whose run-id tag hashes to the name.ProfilesInUsenow also records legacy pool profiles, so an in-use legacy role is kept. The defaultSweep/Decide, which the reaper uses, never reads them.spawn pool drainremoves both names. A failure on the legacy name is printed as a note, not as a failed drain.Why not a queue-gone check: the reaper has no SQS grants. Also, "no instance holds the profile for 24h" already means the pool has no consumer, and
pool createre-creates the role if a pool is ever reused.Gates (each watched failing against a compiling revert)
poolWorkerRoleNamereturns the legacy nameOptions{}pool && false)ProfilesInUseignores legacy profilesIsLegacyPoolWorkerdrops the length checkSweepWithdoesn't list legacy roles_ = legacy)Checks
make checkpasses every step exceptcheck-build-tags, which fails identically on unmodified main in a/private/tmpworktree.make lintreports 0 issues in all 10 modules.make gen-docs+check-docsand semgrep are clean. No AWS calls.