Skip to content

feat: tag the live service spore-host:role=service; keep the reaper's sweeps out of the infra account - #1660

Merged
scttfrdmn merged 3 commits into
mainfrom
feat/750-service-tags
Nov 16, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
feat/750-service-tags

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Part of spore-host/spore-host#750 (epic spore-host/spore-host#752). Companion PR: spore-host/spore-host#753 — tofu default_tags, infra/DEPLOY.md, and the one-off scripts/retag-service-resources.sh.

Why

Most service resources in the infra account (966362334030) carry only spawn:managed=true. Spawn also puts that tag on workload litter, so a litter classifier marked 12 live resources as litter. Every deploy path now adds three more tags, and keeps the existing ones (spawn:managed stays, because the CI role's allow-list relies on it):

  • spore-host:role=service
  • spore-host:component=<id>
  • spore-host:deployed-by=<repo path of the deploy mechanism>

What is tagged, and where

component function log group role other
dashboard-api lambda/dashboard-api/deploy.sh and scripts/deploy.sh, every deploy every deploy setup-dashboard-lambda-role.sh, on create and re-run spawn-user-accounts (setup-user-accounts-table.sh); HTTP API and api.spore.host domain (on create)
dashboard-websocket deploy.sh, every deploy every deploy (shared role) spawn-websocket-connections (create, or re-run on an existing table); WS API (on create)
dashboard-websocket-processor deploy.sh, every deploy every deploy (shared role)
dns-updater scripts/deploy-custom-dns.sh, every deploy every deploy on create, and every run on an existing role
sweep-orchestrator scripts/deploy-sweep-orchestrator.sh every deploy setup-sweep-orchestrator-lambda-role.sh spawn-sweep-orchestration, spawn-availability-stats, spawn-sweeps-us-east-1 (merge)
cost-history-collector scripts/deploy-cost-history-collector.sh every deploy (shared role)
scheduler-handler scripts/deploy-scheduler-handler.sh every deploy scheduler-handler-role.yaml Tags schedules stack tags (create and update) and template Tags; spawn-schedules-<region> buckets tagged on create by pkg/staging
pipeline-orchestrator SAM Function.Tags + PropagateTags template Tags generated role, through SAM spawn-pipeline-orchestration table
ttl-reaper SAM Function.Tags + PropagateTags template Tags generated role and schedule rule, through SAM instance-event bus
(CI) scripts/deploylambdas adds any service tag a function lacks, in the same tag-resource call as spawn:version. It corrects a wrong role or component, and keeps an existing deployed-by GitHubActions-spawn-lambda-deploy is tagged lambda-deploy-ci, and its aws:TagKeys allow-list gains the three keys

The shell keys come from scripts/lib/service-tags.sh. The Go keys come from pkg/servicetags (built on libs v0.52.0 tags), and the deployer's from scripts/deploylambdas/servicetags.go.

Infra-account guard (TTL reaper)

lambda/ttl-reaper/serviceguard.go has two functions:

  • GuardTeardown(accountID string) error refuses 966362334030 (ErrInfraAccount) and an empty ID (ErrAccountUnknown).
  • GuardDelete(accountID, what string, tags map[string]string) error runs the account check, then refuses anything tagged spore-host:role=service (ErrServiceResource).

It is wired in as follows:

  • The net-resource, empty-bucket, per-task role and pool-queue sweeps call GuardTeardown before their first call.
  • Security groups, placement groups and EIPs are checked one by one with GuardDelete, before any discovery stamp.
  • pkg/bucketsweep, pkg/instancerole and pkg/poolqueue gain the same keep rule (KeepService), so spawn cleanup keeps these resources too.

The idle sweep (#1654) does not exist yet. These are the checks it must call.

Gates (each watched failing against a compiling revert)

  • TestServiceCreatesCarryTheServiceTags: a script that creates a role, table, log group, function, queue, API, domain or stack without --tags and a SPORE_SERVICE_TAGS_* value fails it. So does a bucket create with no spore_merge_bucket_tags after it, a lambda tag-resource without the map, or a script that doesn't name itself as deployed-by. It discovers the scripts itself; only member-account scripts are excluded.
  • make lambda-versions fails a SAM template whose function lacks spore-host:role: service.
  • TestServiceTagKeysAgree checks the shell, Go and deployer copies of the keys against each other. TestEveryOperatedComponentHasAServiceComponentID checks each operated Lambda against the shell library's component list.
  • Deployer tests: tags are added, an existing deployed-by is kept, a function that is current and tagged is not re-tagged, and a dry run only reports. The CI role allow-list test now checks all keys.
  • Reaper: unit tests of the guard, a test that the sweeps make no call in the infra account, and a test that the net sweep keeps service SGs and PGs.

To take effect (owner)

  • Re-run scripts/setup-lambda-deploy-ci-role.sh before the next CI deploy. Until then, the CI role can't write the new keys.
  • Redeploy each component, or run spore-host's retag script first (it writes the same values).
  • spawn schedule create now also calls s3:PutBucketTagging when it creates a bucket. It is best-effort: it warns and does not fail.

Gate results

  • make check steps 1–6 pass, run from a copy at a path without a space. In the clone itself, test-hermetic fails only because its unquoted -exec path contains a space.
  • Step 7, check-build-tags, fails here on the base commit as well (local Go 1.27.4). This PR does not cause it.
  • Also passing: shellcheck on every edited script (no new findings), cfn-lint on the 4 templates, and semgrep --config=auto on the changed files (0 findings).

…r's sweeps out of the infra account

Part of spore-host/spore-host#750 (epic spore-host/spore-host#752).

Most service resources in the infra account carried only spawn:managed=true,
which is also the workload-litter tag, and a litter classifier marked 12 live
ones as litter. Every deploy path now adds spore-host:role=service,
spore-host:component=<id> and spore-host:deployed-by=<repo path>:

- scripts/lib/service-tags.sh: the keys and helpers for the shell deploys
- Lambda deploy scripts: function, log group (every deploy), created role
- role/table/bucket/API setup scripts: on create, and on re-run where cheap
- SAM templates: Function.Tags + PropagateTags, log group, table, event bus
- schedules-tables stack tags + template tags; scheduler-handler-role template
- CI deployer: adds missing service tags with the spawn:version stamp; the CI
  role's tag-key allow-list gains the three keys
- pkg/staging: a spawn-schedules-<region> bucket is tagged on create

The TTL reaper refuses its orphan sweeps in 966362334030 or an unresolved
account (GuardTeardown) and never deletes a role=service resource
(GuardDelete; the same keep rule in pkg/bucketsweep, instancerole, poolqueue).

Gates: TestServiceCreatesCarryTheServiceTags (shell creates), the census's SAM
check, TestServiceTagKeysAgree, TestEveryOperatedComponentHasAServiceComponentID.
libs bumped to v0.52.0 for the tags constants.
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/staging/staging.go 77.77% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn marked this pull request as ready for review November 16, 2026 21:09
@scttfrdmn
scttfrdmn merged commit 81c3955 into main Nov 16, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the feat/750-service-tags branch November 16, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant