Repository navigation
feat: tag everything calque creates spore-host:managed-by=calque (calque#227) - #233
Merged
Merged
Conversation
…que#227) Part of the leave-no-trace epic (spore-host/spore-host#752). calque's cleanup (calque#228) can only remove what it can recognise, and the SQS queues, calque-nfs-sg and the IAM roles carried no calque tag at all. Every resource now gets the libs/tags v0.52.0 spore-host:* set plus calque:managed=true, built in one place (internal/calquetags): - SQS calque-pool-<model> / calque-fleet-<run-id>: tagged at create, plus calque:pool-model / calque:fleet-run. An existing queue is converged (ListQueueTags + TagQueue), since CreateQueue returns it untouched. Without sqs:TagQueue the queue is created untagged with a warning, as spawn's taskpool does. - calque-nfs-sg: TagSpecifications at create; an existing group is converged with CreateTags. - calque-real-run-<hash>, calque-pool-worker, calque-fleet-worker roles and profiles: IAMRoleConfig.Tags (spawn v0.131.0 applies them only on create), then converged on every use with TagRole/TagInstanceProfile. This also keeps managed-by=calque if spawn ever stamps its own. - Baked AMIs and snapshots, and every instance calque launches (now including gpuprobe's and scaled-up pool workers, which had no or partial tags). managed-by is calque on these: calque owns their lifecycle; spawn's TTL backstop keys on spawn:* and is unchanged. spawn v0.131.0 appends caller tags after its own, first key wins, and writes no spore-host:* key, so calque's value survives. - S3 objects calque writes from Go, on both sides: PutObject Tagging with calque:run-id; the manifest carries run_id so warmd can tag its results and summary. The instance roles gain s3:PutObjectTagging; without it a write is resent untagged once with a warning, never failed. Converge never moves an existing spore-host:created, so reuse doesn't reset cleanup's grace clock. Pool queues now state MessageRetentionPeriod=345600 (SQS's default, which they already had; any other value would make CreateQueue fail on existing pools). Retention expires messages, not queues: the fleet warning that claimed "12h retention will reap" and the matching queue.go comments are corrected. Tests drive real SDK clients through a new in-process seam (internal/awstest) with libs/tags/tagtest installed, including spawn's own CreateOrGetInstanceProfile and CreateAMI. Reverting the queue or role tagging makes them fail.
Contributor
Author
|
LIVE check (dev 435415984226, us-east-1, 2026-11-16, throwaway queue created and deleted): a tagged |
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 #227. Part of spore-host/spore-host#752 (Leave no trace). Builds on #231 (calque#226).
What changes
Everything calque creates gets the
libs/tagsv0.52.0 set (spore-host:managed-by=calque,spore-host:scope,spore-host:created,spore-host:schema) pluscalque:managed=true. The tags are built in one place,internal/calquetags.calque-pool-<model>pool:<model>, +calque:pool-model; an existing queue is converged (ListQueueTags + TagQueue)calque-fleet-<run-id>run:<id>, +calque:fleet-run,calque:run-idcalque-nfs-sgTagSpecifications,vpc:<id>; an existing group gets CreateTagscalque-real-run-<hash>/calque-pool-worker/calque-fleet-workerspawn:*onlyIAMRoleConfig.Tagson create, converged on every use with TagRole/TagInstanceProfile;bucket:<b>/pool-workers/fleet-workerscalque:baked-*run:<id>calque:*run:<id>calque:managed,calque:command=gpuprobepool scalecalque:pool-model,calque:roleonlypool:<model>Taggingwith managed-by, schema, scope,calque:run-idmanaged-byon calque-launched instances iscalque. calque terminates them, drains the fleet and deletes the pool, so it owns their lifecycle. spawn's TTL backstop keys onspawn:*and still applies. spawn v0.131.0'sbuildTagsappends caller tags after its own and keeps the first of any repeated key. It writes nospore-host:*key, so calque's value survives. I checked this with a throwaway test against the v0.131.0 source: a callerspawn:managed=falseis dropped, and a callerspore-host:managed-by=calquesurvives. If spawn#1652 adds its ownspore-host:managed-byto the instance tags, it will win over calque's. That needs handling on the spawn side; see the comment on spawn#1652. For roles, calque's TagRole after create already corrects it.Converge never moves an existing
spore-host:created, so reuse doesn't reset cleanup's grace clock. A role, SG or queue from an older calque gets "now".Queue expiry. Pool queues now set
MessageRetentionPeriod=345600. That is SQS's default, which they already had. Any other value would makeCreateQueuefail with QueueAlreadyExists on every existing pool. Retention expires messages, not queues. This PR corrects the fleet warning "12h retention will reap", theRunQueueName/CreateRunQueuecomment and theDeleteQueuecomment, which all claimed otherwise. The real deleter is calque#228.New IAM actions
iam:TagRole,iam:TagInstanceProfile,s3:PutObjectTagging,sqs:TagQueue,sqs:ListQueueTags.ec2:CreateTagsandiam:GetRole/iam:GetInstanceProfilewere already needed.s3:PutObjectTaggingon the staging/results bucket (RealRunPolicy, WorkerPolicy, FleetWorkerPolicy).[tags] WARNING. S3 resends the write untagged once and then stops asking for tags. This matters for a pool worker still on an older grant.docs/guide/getting-started.mdlists the actions.Tests
internal/awstest: an in-process SDK seam. It answers at the end of Initialize, so a real client runs its own middleware, including tagtest's Detector. tagtest only sees real SDK clients, so it can't check calls made through an interface fake.CreateOrGetInstanceProfile(pool and real-run roles; CreateRole and CreateInstanceProfile must be tagged);EnsureNFSSecurityGroup; spawn's realCreateAMI(image and snapshot specs); UploadArtifacts/UploadDockerfile/WriteManifest/S3Sink; S3Results; warmdputJSON.TestCreatePoolQueue_TaggedAtCreateandTestCreateRunQueue_TaggedAtCreateagainst main'squeue.gofail withtagtest: SQS CreateQueue would create a resource without spore-host:managed-by=calque. Dropping theTags:line fromensureWorkerProfilefailsTestEnsureWorkerProfile_SpawnCreatesTheRoleTaggedon both CreateRole and CreateInstanceProfile.Not tagged yet
Objects the instance writes with
aws s3 cp/syncaren't tagged: bootstrap logs, ami-bake markers, occupancy files and Volume commits.aws s3 cpcan't tag. Follow-up: #234.Not verified against AWS
None of this has been run against AWS; the tests use fakes only. Two things depend on SQS behaviour I could not check live:
CreateQueueignores tags when the queue already exists. I'm relying on the documented rule that only attributes must match, and the code has a fallback: it retries untagged on QueueAlreadyExists.CreateQueueneedssqs:TagQueue, as documented.Both are worth one live
calque pool createagainst an existing pool before release.Gates
gofmt -l .clean ·go vet ./...·go test ./...(uv present, parse contract tests ran, 0 skips) ·go test -raceon changed packages · golangci-lint 0 issues (local v2.15.0; CI pins v2.12.2) ·uvx ruff check .· semgrep on changed files: one finding,dangerous-exec-commandatcmd/warmd/main.go(the occupancy sampler). It's on a line this PR doesn't touch, and it's identical on main.libs v0.51.2 → v0.52.0 (now direct). spawn stays at v0.131.0.