Repository navigation
Reaper account-idle sweep (report mode), lease marks on every creator, --if-idle-for from the lifecycle verdict; keep the boundary (#1654, #1664) - #1665
Merged
Conversation
…reator, --if-idle-for from the lifecycle verdict; keep the boundary (#1654, #1664) Part of #1654 (leave-no-trace, spore-host/spore-host#752). Fixes #1664. - lambda/ttl-reaper: the account-idle sweep (REAPER_ACCOUNT_IDLE, default report; reap reports until #1657). Per member account and scope (each scanned region, and global), the verdict from every signal, a read failure counting as active: spawn instances pending through stopped, egress proxies, FSx being made or just made, pool queues in use, calque's footprint (pkg/calquefootprint), and the infra account's sweeps, pipelines and pending schedules for that account. Observe in the member's spore-host-lifecycle table; after REAPER_ACCOUNT_IDLE_GRACE (24h): Claim, re-check (activity -> Release), plan with spawn footprint's scan and rules, footprint.Execute in ModeReport with the real lease and a deleter that cannot delete, log every row and "account-idle REPORT account=... region=... would_delete=N kept=M", Release. Never Finish, never delete. GuardTeardown first. A scope no creator has marked (no item / epoch 0) is lease unavailable and skipped; the sweep never creates the table for it. - IAM: the member role and ScanSelfStatements gain the lease table (exact name) and read-only footprint/calque reads; the SAM template gains Scan on the sweeps and pipelines tables. No reaper role can delete a policy (gate). - pkg/lifecyclemark: Mark before every create a teardown could delete; warn once and continue when it fails (lease unavailable); a gate (TestEveryCreatorMarksTheLease) discovers the creators. - spawn reaper teardown --if-idle-for: idleness from the lifecycle verdict; the undetermined and not-running refusals stay. - #1664: SweepSporedPolicies never deletes spore-host/spawn-instance-boundary nor a policy tagged spore-host:permanent=true (or with unreadable tags). - iamcoverage: TransactWriteItems maps to the item actions DynamoDB authorizes it by.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ts it (#1654, #1666) A failed or denied lifecyclemark.Mark printed a warning once per process, which is every `spawn launch` for any user whose IAM lacks the lease actions (most users today: nothing spore.host provisions grants them, spawn#1666). It now writes only to spawn's diagnostic log (~/.spawn/spawn.log, stderr with --verbose); the account just counts as lease unavailable. The one user-visible line left is a wait past 30 s, when a teardown really holds the lease. - spawn doctor: an "idle teardown" check, read-only (DescribeTable, and an UpdateItem whose condition can never hold), Warn naming the principal. - Gates: TestEveryCreatorMarksTheLease now also checks the failure path makes no fmt/log call and names no os.Stdout/os.Stderr, and does log; pkg/aws's TestADeniedLeaseMarkIsSilentAndTheCreateProceeds runs a real creator with a denied lease and asserts empty stdout/stderr, a diagnostic line, and the create.
Contributor
Author
|
Owner decision (2026-11-20): yes, the reaper's member role must never read users' S3 object contents. The permanent-deny entry in |
Contributor
Author
LIVE launch check (dev 435415984226, us-east-1, 2026-11-20, CLI built from this branch at ba22e44)
CI: the Tier 0 failure ( Owner decision recorded above: the member role never reads S3 objects. Deploy (later, with owner approval): the member stack |
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.
Part of #1654. Fixes #1664.
Report mode only. Nothing in this PR deletes anything. The reap flip is #1657.
#1664: the boundary is never swept
instancerole.SweepSporedPolicies(run byspawn cleanup --instance-roles) used to deletespore-host/spawn-instance-boundary. Now:KeepBoundaryPermanent, pointing atspawn setup-account --remove+ docs for the permanent boundary #1656). This applies whether it is in use, unused, old or young.spore-host:permanent=trueis kept. So is one whose tags can't be read (fail closed). The sweep reads tags only for delete candidates, and so needsiam:ListPolicyTags.PolicyAPIno longer hasListPolicyVersions/DeletePolicyVersion.iam:DeletePolicy, so no Deny was needed.TestReaperCannotDeleteAPolicy(pkg/reaperiam) fails if any of the three policy copies ever grantsiam:DeletePolicy,DeletePolicyVersionor an iam wildcard.Lease marks on every creator (
pkg/lifecyclemark)Mark(ctx, cfg, scopes...)callslifecycle.MarkActive(spawn, scope)before a create. The scope is the region, orglobal(us-east-1) for IAM.A denied or failed mark never fails the create, and prints nothing the user sees.
~/.spawn/spawn.log, or stderr with--verbose.setup-accountcreates only the boundary, and every role spawn creates is a machine role. That gap is filed as Provision the user-side lifecycle-lease IAM (spore-host-lifecycle) instead of documenting it #1666.spawn doctor"idle teardown" check.DescribeTable, then anUpdateItemwhose condition can never hold. A ConditionalCheckFailed proves the write is authorized and that nothing was written.Where marks are called:
spawn reaper deploy, bot and onboard roles, setup-account, the sweep role, the egress proxy,schedule create, and detached sweep submit.Gate
TestEveryCreatorMarksTheLease:Mark, then walks each command with those functions as cuts. Any creating action still reachable fails the gate.footprintspawn.DeletableTypes()plus FSx. There is one exemption, the doctor's DryRun probe.os.Stdout/os.Stderr, and does call the diagnostic logger.Behavioural test
TestADeniedLeaseMarkIsSilentAndTheCreateProceeds(pkg/aws). It runs a real creator through a DynamoDB client that answers AccessDenied, and checks:TestLeaseRequiredActionsAreWhatMarkCallsholds the action list that the log line and doctor name to whatMarkcan call.Reaper
account-idlesweep (lambda/ttl-reaper/accountidle.go)REAPER_ACCOUNT_IDLE=off|report|reap, defaultreport.reapalso reports. The grace isREAPER_ACCOUNT_IDLE_GRACE, default 24h.AccountIdle,AccountIdleGrace. Deploy flags:spawn reaper deploy --account-idle/--account-idle-grace.GuardTeardown(account)runs first. The infra account, and an unidentified account, are refused before any read.global. Any read failure counts as active.spawn:managed=true)spawn:egress-proxy)spawn-pool-*queues in use (pkg/poolqueue keep reasons, workers over every enabled region)calquefootprint.Inventoryspawn-sweep-orchestration,spawn-pipeline-orchestration,spawn-schedulesGet. If there is no item, or Epoch is 0, the lease is unavailable: skip, and never create the table. If the read fails, skip with a warning.Observe(active).Claim.Release.pkg/aws.AccountFootprint(thespawn footprint -o jsonscan) andpkg/footprintspawn.footprint.ExecuteinModeReportwith the real lease andteardown.NewReportOnly. That deleter has no delete reachable, so the reaper role is never asked to grant one.Release. It never callsFinish.Releaserestarts the grace, so an idle account is reported once per grace period.Log lines:
calque module: imported
I imported
github.com/spore-host/calque/pkg/calquefootprint. The cycle check was clean:go mod tidyworks.replace spawn => ../..wins over calque'sspawn v0.131.0pin.go list -depsgrew 502 → 523.Caveats:
main(fced2c6). Bump it when calque tags a release.require spawnline reads v0.131.0. That's cosmetic: the replace wins.calquefootprint.Collectcan list S3 objects forOptions.Buckets. The reaper passes none, but the call graph can't see that. It is ledgered as a permanent denied call ininternal/iamcoverage/gaps_test.go: the member role reads no S3 objects or object tags.spawn reaper teardown --if-idle-forreaperdeploy.LeaseIdleness, aGetper scanned region plusglobal), not from log lines.--account-idle-grace 30dto wait 30d.IAM changes, for PutRolePolicy and simulation
ttl-reaper-cross-account-role.yaml), mirrored in the SAM ScanSelf branch andreaperiam.AccountIdleStatements:dynamodb:GetItem, UpdateItem, PutItem, DeleteItem, ConditionCheckItem, DescribeTable, CreateTable, TagResourceonarn:aws:dynamodb:*:${AWS::AccountId}:table/spore-host-lifecycle.*:cloudformation:DescribeStacks, dynamodb:ListTables, dynamodb:ListTagsOfResource, ec2:DescribeImages, ec2:DescribeNetworkInterfaces, ec2:DescribeSnapshots, ec2:DescribeVolumes, events:ListEventBuses, events:ListRules, events:ListTagsForResource, lambda:ListFunctions, lambda:ListTags, logs:DescribeLogGroups, logs:ListTagsForResource, scheduler:GetSchedule, scheduler:ListSchedules, sns:ListTopics, sns:ListTagsForResource, tag:GetResources.*:iam:GetRole, ListRoleTags, ListAttachedRolePolicies, ListInstanceProfilesForRole, GetInstanceProfile, ListInstanceProfiles, ListInstanceProfileTags, ListPolicies, GetPolicy, ListPolicyTags.iam:ListRolePolicies, GetRolePolicyonrole/calque-*.sqs:GetQueueAttributes, ListQueueTagsoncalque-*.sqs:GetQueueUrladded to thespawn-pool-*statement.s3:ListAllMyBucketson*(names only).dynamodb:Scanonspawn-sweep-orchestrationandspawn-pipeline-orchestration(us-east-1). These are also inScanSelfPolicyDocument, forspawn reaper deploy. A missing table reads as no records.docs/reference/cli-iam-actions.mdis regenerated. Launch paths now listdynamodb:ConditionCheckItem, UpdateItem, PutItem, DeleteItem, DescribeTable, CreateTable, TagResource. The umbrella baseline doc is docs(iam): LifecycleLease in the user baseline (spawn#1654) spore-host#755; spore.host does not provision these for users yet (Provision the user-side lifecycle-lease IAM (spore-host-lifecycle) instead of documenting it #1666).crossAccountGrantedActionsnow parses the role instead of regex-scraping a hand-listed set of services; the regex missed seven services. Existing scope gates were adjusted, with comments: S3, SQS, the schedule grants, and taskiam's staging list.Tests and gates
accountidle_test.go):NewReportOnlygiven a real delete;--if-idle-foractive and grace checks removed;spawn cleanup --instance-rolesdeletes the permissions boundary (owner decision: permanent) #1664);Markcall removed (the gate fails);*, andiam:DeletePolicy, added to the member template.make checkpassed (run from a space-free copy);make api-snapshot(two additions to pkg/aws:GatherFootprint,AccountFootprint);make cli-iam-actions;make gen-docs; reaper IAM coverage, drift and template tests; semgrep on the 54 changed files (0 findings).Deploy notes
To deploy, redeploy the member stack (
spawn-ttl-reaper-ec2) first, then the production reaper. Until the member stack is redeployed, each scope logs "lease unavailable" and nothing else changes.Before deploying, run a real PutRolePolicy on the new statements, and simulate them both ways (allow and deny).