Repository navigation
feat(cleanup,reaper): delete orphaned schedule params (#1398) - #1414
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
…1398) pkg/schedulesweep decides when a schedules/<id>/params.yaml in a spawn-schedules-* bucket is orphaned: no record names it (consistent full scan, after the listing), older than RecordTTLMargin, tagged as a schedule's params (not a queue config, current or pre-#1399), in a bucket named for the account. Fails closed on an unreadable table. instancerole.ScanSchedules is now shared by the role sweep and this one.
#1398) Off/report/reap, unset = report, threaded through the template (ScheduleParams), the Makefile (SCHEDULE_PARAMS) and spawn reaper deploy --schedule-params, with the preservation gate. Runs once per run on the reaper's own credentials. IAM in pkg/reaperiam.ScheduleParamsSweepStatements and the SAM template: s3:ListAllMyBuckets, s3:ListBucket on spawn-schedules-* conditioned on s3:prefix schedules/*, and s3:GetObjectTagging + s3:DeleteObject on spawn-schedules-*/schedules/*.
The same pkg/schedulesweep rule from a workstation, on spawn's infra account credentials, dry-run aware. iamcoverage now claims call sites by package, so the sweep's s3:ListBucket/DeleteObject are held to the reaper's own role, not the member role. Docs, README, CHANGELOG.
scttfrdmn
force-pushed
the
fix/1398-schedule-orphan-sweeper
branch
from
October 29, 2026 05:41
4cf4ab3 to
657a42c
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 #1398
Since #1382, schedule params (
spawn-schedules-<region>/schedules/<id>/params.yaml) have no expiry. Three paths leave them orphaned once the record's TTL deletes the record. This adds the named deleter: one rule inpkg/schedulesweep, used by the TTL reaper (REAPER_SCHEDULE_PARAMS) and byspawn cleanup --schedule-params. It follows the #1301 / #1351 / #1378 pattern.Deletion rule (all must hold)
spawn-schedules-<region>orspawn-schedules-<this account>-<region>, found with ListBuckets(Prefix). Every call names the account asExpectedBucketOwner, and each bucket is read in its own region.schedules/<id>/params.yaml.spawn-scheduleshas thatschedule_idor names that bucket/key. The table is read with a full consistent Scan, done after the objects are listed. Records are read byinstancerole.ScanSchedules, now shared with the Reaper InstanceRoles would delete a spawn-instance-* role that an enabled schedule still names #1378 role sweep.scheduler.RecordTTLMargin(30 d) old.Component=schedulerwithScheduleID=<id>and have noQueueIDtag, and<id>must matchsched-YYYYMMDD-HHMMSS(the formGenerateScheduleIDgives).UploadQueueConfigwrites the same key.Component=queue&QueueID=....Component=scheduler&ScheduleID=queue-...). Only the id form tells them apart.Fail closed: if any Scan page fails or any record can't be decoded, the sweep deletes nothing anywhere. The reaper counts this in
schedule_params_unreadable, and also inErrorsunless the cause is AccessDenied. The CLI refuses.Reaper switch
off|report|reap, defaultreport, withREAPER_DRY_RUNoverriding. It is set by:ScheduleParamsSCHEDULE_PARAMSspawn reaper deploy --schedule-paramspkg/reaperconfig(Settable and the census)The value survives a deploy that doesn't name it (
TestScheduleParamsSurvivesAMakeDeploy). The sweep runs once per run, on the function's own credentials.IAM
Source:
pkg/reaperiam.ScheduleParamsSweepStatements, copied into the SAM template (unconditional, beside the #1378 read) and intoScanSelfPolicyDocument(spawn reaper deploy):s3:ListAllMyBucketson*(ListBuckets has no resource ARN and returns names only)s3:ListBucketonarn:aws:s3:::spawn-schedules-*, withStringLike s3:prefix = schedules/*s3:GetObjectTaggingands3:DeleteObjectonarn:aws:s3:::spawn-schedules-*/schedules/*The member role (
ttl-reaper-cross-account-role.yaml) is unchanged: schedules live in the reaper's own (infra) account, wherespawn schedule createwrites them withLoadInfraAWSConfig.TestScheduleReadIsOnTheReapersOwnRoleOnlyenforces this.internal/iamcoveragecan now claim call sites by package, sopkg/schedulesweep's calls are checked against the function role.CLI (
make cli-iam-actions):spawn cleanupnow also needss3:ListAllMyBucketsands3:GetObjectTagging, both already needed by other commands. They are used only for--schedule-params, in the infra account.Deploy steps
lambda/ttl-reaper:make deploy(noSCHEDULE_PARAMS). The stack getsScheduleParams=reportand the new grants. Snapshot the stack parameters before the deploy and diff them after; expect zero drift apart from the new parameter.schedule_params_*) and theWOULD delete schedule paramslines.make deploy SCHEDULE_PARAMS=reap.No member-role redeploy is needed.
Checks
make check,make lint(0 issues),semgrep scan --config=auto --error .,make check-docsandmake api-snapshot(no change) all pass. Each gate was watched failing against a revert that compiles; see the agent report.