Repository navigation
feat(cleanup,reaper): remove spawn's empty staging and results buckets (#1301) - #1322
Merged
Merged
Conversation
#1301) spawn cleanup --buckets and the reaper's REAPER_EMPTY_BUCKETS sweep (off|report|reap, default report) delete spawn-staging-<acct>-<region> and spawn-results-<acct>-<region> once empty for 7 days, tracked with a spawn:empty-since tag. No object is ever deleted. The staging bucket is never listed (#1274); S3's BucketNotEmpty is its emptiness check. IAM scoped to arn:aws:s3:::spawn-staging-* and spawn-results-* in all three policy copies; setting threaded through make deploy, the SAM template and spawn reaper deploy with preservation. Fixes #1301
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 #1301
Leave no trace for spawn's two per-account, per-region buckets:
spawn-staging-<account>-<region>(#1293) andspawn-results-<account>-<region>. No object is ever deleted; only a bucket that is already empty, for 7 days, is removed. Deleting results data stays opt-in (#1076).What
pkg/bucketsweep(new, no pkg/aws dependency): the decision and the delete, shared by the CLI and the reaper. A bucket is deleted only if ALL hold:ExpectedBucketOwner= the account on every call;spawn:managed=true, or an untagged results bucket on that exact name (creation tagging used to be best-effort and its failure ignored, so an untagged one on the exact name, owned by the account, is spawn's);ListObjectVersions(versions + delete markers, so versioned buckets count) andListMultipartUploads; the staging bucket is never listed (no spawn role may list it, User data: fetch the bootstrap from S3 behind a small verifying stub, removing the 16 KiB ceiling (follow-up to #1246) #1274, enforced byTestNoGeneratedPolicyReachesTheStagingBucket), so its emptiness check is S3'sBucketNotEmptyrefusal onDeleteBucket(its objects all expire after a day);spawn:fsx-stack-nametag; for results, no lifecycle rules (a re-created bucket would silently losespawn results lifecycle --applytiering);spawn:empty-sincestamp (written on the first empty sighting, removed when seen in use or by a launch that uses the bucket) at least 7 days old.spawn cleanup --buckets:--dry-runwrites nothing (not even the stamp); otherwise it stamps, then asks before deleting and re-checks each bucket just before the delete.REAPER_EMPTY_BUCKETS/EmptyBuckets/EMPTY_BUCKETS/spawn reaper deploy --empty-buckets:off|report|reap, defaultreport(logs, writes nothing; armingreapstarts the 7 days). DryRun wins. Runs per account per region. Summary:empty_buckets_scanned/stamped/deleted/would_delete/failed. Deployed value preserved on all three paths.DELETEDadded to the idleness action sentinels.arn:aws:s3:::spawn-staging-*:s3:GetBucketTagging,s3:PutBucketTagging,s3:DeleteBucketarn:aws:s3:::spawn-results-*:s3:ListBucket,s3:ListBucketVersions,s3:ListBucketMultipartUploads,s3:GetBucketTagging,s3:PutBucketTagging,s3:GetLifecycleConfiguration,s3:DeleteBucketspawn:empty-sincestamp (best effort):EnsureStagingBucketandCreateS3BucketIfNotExists(only for spawn-staging-/spawn-results- names).spawn:managed=true+spawn:purpose=task-resultsrather thanspawn:fsx-backing-bucket=true(Fixed). S3 defaults supply BPA/SSE-S3/BucketOwnerEnforced, as before; staging is re-created fully configured byEnsureStagingBucket. Tests cover both.spawn footprintshows the stamp and the date the bucket becomes deletable.spawn cleanup(plain) no longer offers aspawn:managedbucket as removable and then fails with "don't know how to remove" (Fixed);parseARNnames an S3 bucket correctly.Before deploying
Redeploy the
spawn-ttl-reaper-ec2member stacks (and the reaper stack for ScanSelf) before armingreap. Without that, the sweep logs each bucket it could not read and what to redeploy, and counts it inempty_buckets_failed. It does not count it as an operational error.Not verified against AWS (no AWS calls were made): run PutRolePolicy plus allow/deny simulation on the statements above, and check that HeadBucket/GetBucketTagging on a missing bucket returns 404 under these grants.