Repository navigation
fix(task): grant spored self-management baseline on scoped task profiles (#406) - #407
Merged
Merged
Conversation
…les (#406) Root-caused by the increment-2 smoke test: a 'spawn task run' instance never self-terminated on completion, and would not have enforced its TTL in-instance either. SSM into the box showed spored v0.81.0 running but: Config: TTL=0s, IdleTimeout=0s Could not load config from tags: UnauthorizedOperation ec2:DescribeTags The scoped IAM profile task run creates (via IAMRoleConfig.InlinePolicyJSON for per-task S3 access) REPLACED the default spored role entirely — and the InlinePolicyJSON path bypasses buildInlinePolicy, which is the only place that always prepends spored's EC2 self-management grants. With no ec2:DescribeTags, spored can't read spawn:ttl / spawn:on-complete, so on_complete never fires and TTL isn't enforced in-instance (only the reaper backstops it). Fix: extract the spored self-management statements into sporedSelfManagementStatements() + sporedBaselinePolicyDoc(), and attach that baseline as a second inline policy whenever InlinePolicyJSON is set (create + update paths). Also tag the completion file explicitly in task run. Verified end-to-end on real AWS: task instance self-terminated ~4min after completion, leak-check clean. Closes #406
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.
Summary
Fixes #406 — a
spawn task runinstance did not self-terminate on completion (and would not have enforced its TTL in-instance either). Root-caused by the increment-2 smoke test.Root cause
SSM'd into a live task instance: spored v0.81.0 was running,
/tmp/SPAWN_COMPLETEexisted with the right JSON, but the spored log showed:The scoped IAM instance profile
task runcreates (viaIAMRoleConfig.InlinePolicyJSON, added in #404 for per-task S3 staging access) replaced the default spored role entirely — and theInlinePolicyJSONpath bypassesbuildInlinePolicy, which is the only place that always prepends spored's EC2 self-management grants. With noec2:DescribeTags, spored can't readspawn:ttl/spawn:on-complete, so:on_complete=terminatenever fires, andThis was the "on-complete didn't fire" symptom from the first smoke test; the real scope is broader (TTL too), which is why it's worth fixing before release.
Fix
sporedSelfManagementStatements()+sporedBaselinePolicyDoc()(shared withbuildInlinePolicy, so the two can't drift).InlinePolicyJSONis set, attach that baseline as a second inline policy (spored-baseline-policy) on both the create and update paths.task runalso tags the completion file explicitly (CompletionFile/CompletionDelay), so on-complete doesn't depend on provider-side defaulting / tag-visibility timing.Verification
Real AWS, end-to-end (spore-host-dev, t3a.small, TTL 15m): task launched → ran → wrote
completion.json(exit 0) → self-terminated ~4 min after completion. Leak-check across all smoke task-ids: clean, zero orphans. (The pre-fix run stayed running until manually killed.)Unit:
TestSporedBaselinePolicyDoc(baseline carries DescribeTags/Terminate/CreateTags, valid JSON),TestBuildInlinePolicyIncludesBaseline(refactor didn't drop the baseline),TestTaskLaunchConfig(completion-file tagged).TestFlagConventions/TestTier0pass; Semgrep clean.Closes #406