Repository navigation
feat: tag everything spawn creates spore-host:managed-by=spawn (#1652) - #1661
Merged
Merged
Conversation
Every resource spawn creates now carries the libs/tags spore.host set (managed-by=spawn, created, schema, and scope/owner where they apply) beside the unchanged spawn:* tags: instances, volumes, Spot requests, security and placement groups, key pairs, launch EIPs, instance roles and profiles, the /spore-host/spored-* managed policies, the spawn-instance boundary (plus spore-host:permanent=true), results/FSx/ staging/schedules buckets, pool queues, FSx and DRAs, AMIs and snapshots, the self-hosted reaper, the egress proxy, the ISO-import role/profile/Image Builder config, the portal-onboard and bot roles, the hybrid registry table and pipeline topics. No spore-host:role. A caller's spore-host:* keys win (LaunchConfig.Tags, IAMRoleConfig.Tags), so calque's and lagotto's managed-by survive. Existing reusable resources are converged add-only. A missing tag permission never fails a command. The tagtest Detector runs on real SDK clients (internal/sdkanswer) for every create path. Fixes #1652
Contributor
Author
LIVE check (dev 435415984226, us-east-1, 2026-11-16, CLI built from this branch)Two t3.micro launches, both reached spored readiness: a default launch (
Both terminated. Leak check: no a2-* instances, unattached EIPs or available volumes. The per-launch role is left for the reaper's 24 h instance-role sweep. Follow-up filed: #1662 (deny the instance role rewriting its own |
scttfrdmn
marked this pull request as ready for review
November 16, 2026 22:05
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 #1652. Part of the Leave-no-trace epic spore-host/spore-host#752. Builds on #1660 (
pkg/servicetags, libs v0.52.0).What changes
Everything spawn creates carries the
libs/tagsset beside itsspawn:*tags, which are unchanged (the reaper,spawn cleanupand spored key on them, and TTL enforcement still does). Helpers:pkg/sporetags(For,Fill= caller wins,Converge= add-only,Permanent,ScopeGlobal).buildTags)spawn:*managed-by=spawn,created(launch instant; re-anchored byAnchorLaunchTagsfor detached sweep members),schemaLifecycleTags)spawn:managed,spawn:created, Name, purposemanaged-by,created,schema, andscope=<region>+ownerfromClientmethodsmanaged-by/scope/ownercarry overspawn:*scope=<region>,ownerspawn-instance-*role + profilespawn:*scope=global,owner; existing ones convergedspored-instance-role+ profilespawn:managedonly/spore-host/spored-*-v<N>managed policiesTagPolicy)spore-host/spawn-instance-boundaryspore-host:permanent=true;spawn setup-accountconverges an existing one (a launch never writes to it)SpawnSweepCrossAccountRolespawn:managedSpawnBotCrossAccount,spore-portal-onboardrolesspawn:*/Purposecomponent=portal-onboard); onboard role convergedcomponent=iso-import; convergedResourceTagsonly)Tags= spore set; build instances'ResourceTagstoospawn:managed(+ purpose/FSx)scope; existingspawn-results-*/spawn-staging-*convergedspawn:managed, purposecreatedpkg/staging)spawn:managed,spawn:pool-run-idscope=<region>spawn:*/ untagged DRAcreate-ami)managed-by/owner; freshcreated,scope=<target>spawn:managed, from-snapshotpkg/reaperdeploy): role, log group, bucket, function, both rulesspawn:*/ rules untaggedcomponent=ttl-reaper; role converged; function re-tag keeps firstcreatedspawn:pipeline-idcreated= pipelineCreatedAt(SNS rejects a re-create with different tags; legacy topics fall back)Nothing gets
spore-host:role(#1660's keep-rules are untouched). spawn creates no launch templates. Not tagged: ENIs (deleted with the instance; tagging them would needec2:CreateTagson network-interface, which the documented baseline does not grant), Capacity Block reservations (expire on their own; tagging would make a purchase depend on a new grant), the DRA spored creates on-instance (instance role has nofsx:TagResource).Precedence (calque#233, lagotto#331)
Chosen: spawn writes each
spore-host:*key only when the caller did not supply it. No new API field.buildTags: the spore set is appended in a new Section 7b, after the caller's tags, withappendTagUnique(first wins).spawn:*keys stay spawn's.buildIAMTags:sporetags.Fillover a copy ofIAMRoleConfig.Tags; it no longer mutates the caller's map.sporetags.Converge): it never changescreated,owner, or amanaged-byanother tool set.TestSporeTags_LaunchKeepsTheCallersManagedBy(Detector for calque; instance + volume specs),TestSporeTags_InstanceRoleKeepsTheCallersManagedBy(role + profile, then reuse),TestSporeTags_BuildTagsCallerWinsAndNoDuplicates(lagotto).Tag budget
An instance gets three keys (
managed-by,created,schema), not five: its region andspawn:iam-useralready say scope and owner, and the documented maximal launch had exactly three slots to spare under AWS's 50 with spored's reserve (TestMonitoringSettingsFitOnAMaximalLaunchnow 41 + 9 = 50). A caller can still set scope/owner. The budget fixtures intags_limit_test.go/launch_config_object_test.gowere adjusted, with the reasons in their comments.IAM
New actions (
docs/reference/cli-iam-actions.mdregenerated):iam:TagPolicy: every command that sets up an instance role, andspawn setup-account.imagebuilder:TagResource:spawn image import.events:TagResource:spawn reaper deploy.A missing tag permission never fails a command: a tagged
CreatePolicy, Image Builder create orPutRulerefused as AccessDenied is retried untagged with one warning, and a denied converge changes nothing (silently, so baseline users don't get a warning on every launch). The documented user baseline (spore-host/spore-hostdocs/reference/iam-permissions.md) needsiam:TagPolicyonarn:aws:iam::*:policy/spore-host/spored-*; without it the spored policies stay untagged.spawn setup-accountneeds no change (it runs as an admin, and now converges the boundary's tags). The nested-spawn role does not get the IAM tag actions (listed innestedSpawnNotGranted: only reached by the role-setup paths a nested spore skips).Tests
internal/sdkansweranswers SDK calls in-process at the end of Initialize, so real clients run their own middleware, including thetagtestDetector. Wired into: launch (fake EC2 over HTTP), net resources and key pair, instance-role setup, spored role, boundary, ISO import, create-ami, buckets, FSx (pkg/aws); egress-proxy groups + instance; pool queue; schedules bucket; reaper deploy; pipeline topic stability. Allow-list entries, each with a reason: S3CreateBucket(tagged by thePutBucketTaggingthat follows, which the Detector checks), S3PutObject(reaper artifact zip in the tagged bucket), IAMCreatePolicyunder the calque Detector (the spored policy is spawn's) and in the AccessDenied-fallback test.Converge tests: an existing untagged spored policy, role and profile get the tags and keep a pre-existing
created(TestSporeTags_SporedRoleAndConverge); untagged boundary →Tagged, re-run no-op; ISO-import role/profile; reaper role.Revert checks (each a compiling revert, watched fail):
Tags: iamtags.FromMap(nil)→tagtest: IAM CreatePolicy would create a resource without spore-host:managed-by=spawninTestSporeTags_InstanceRoleSetup.Tags: iamtags.FromMap(nil)→tagtest: IAM CreateRole ... without spore-host:managed-by=spawninTestSporeTags_ISOImport.iamTagMapoverwriting instead ofFill→IAM CreateRole ... has spore-host:managed-by=spawn, want calque(and CreateInstanceProfile).buildTags→EC2 RunInstances ... TagSpecifications[0] (instance) has spore-host:managed-by=spawn, want calque; TagSpecifications[1] (volume) ....Tags: nil→tagtest: EventBridge PutRule would create a resource without ....Gates
make check, run from a space-free worktree (the clone lives under/Volumes/External HD/..., andmake check's hermetic-exec path andlambda/dashboard-api's setup-all script test break on the space): fmt, vet, every-GOOS vet, staticcheck, golangci-lint 2.15.0 (0 issues, 10 modules), hermetic short tests, nested modules, tidy all pass.check-build-tagspassed from a non-symlinked path (/private/tmp); from/tmpit fails identically onmain, a symlink artefact of the script's path comparison.make api-snapshot: one addition,BoundaryOutcome.Tagged.make cli-iam-actions: regenerated (above).lambda/ttl-reaper/testdata/egress_proxy_tags.jsonregenerated (TestReaperFixtureIsCurrent -update); the reaper's tests pass.docs-gen: no change.semgrep scan --config=auto --erroron the 45 changed Go files: clean (onenosemgrepon the test answerer'sMethodByName).Not run against AWS; all tests are hermetic.