Repository navigation
feat(task): results_prefix — put a task's durable records where you want them - #658
Merged
Merged
Conversation
…ant them outputs[].destination was always fully caller-controlled: per object, to any bucket, with the launch role's inline policy built from whatever the spec names (cmd/task.go taskStagingPolicy). But completion.json, .exitcode and command.log always landed at s3://spawn-results-<account>-<region>/tasks/<task_id>/ with no override — resultsBucket was computed from the account and region and there was no flag or env var for it. So a consumer wanting its own layout read TWO places: its own prefix for results, and the fixed spawn path for the terminal signal. results_prefix on the TaskSpec collapses that to one. Omitting it is byte-identical to before, which matters because six workflow adapters poll the default path literally. Three things worth noting beyond the issue: 1. `spawn task status` needed a flag. It is given a task id, not a spec, so it cannot infer a results_prefix the spec set — setting one would have broken `task status` outright. --results-prefix fixes that; without it status stays on spawn's default. 2. spawn must NOT create a bucket the caller named. It creates its own default bucket before launch so a first-ever task cannot hit NoSuchBucket, but a caller-supplied bucket that does not exist is now an error: creating it would mean a typo leaves a stray bucket behind and the run still reports success, which is the opposite of what someone pointing at their own storage expects. IsDefaultResultsBucket gates that, and its test pins the near-misses (right account wrong region, right region wrong account). 3. The prefix is resolved ONCE, by the caller, and passed to the wrapper, the flush hook (#632) and the policy. Previously each derived it from a bucket name, which is how a future override reaches one and misses another — the same shape as #625's grant gap. GenerateWrapper/GeneratePooledJobScript/ GenerateFlushScript now take the resolved prefix; the pooled worker resolves it the same way. SplitS3URI rejects anything that is not s3://bucket/... rather than treating a typo'd scheme as a bucket name. The 47 test call sites keep naming a bucket, via three test-local shims that translate to the prefix the old signature would have derived — the assertions read better that way and the shims document the change. Full suite, vet, gofmt and check-docs pass. Fixes #646
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
scttfrdmn
added a commit
that referenced
this pull request
Oct 5, 2026
…#717) task status reported every finished task as "running" and --wait polled to TTL and exited 1 on tasks that had succeeded in seconds. EffectiveResultsPrefix already ends in the task id. completionKey appended it again. So the wrapper wrote — and spawn PRINTED — tasks/<task_id>/completion.json while the reader fetched tasks/<task_id>/<task_id>/completion.json which 404s, and the read path correctly reads a 404 as "no record yet". Verified against the reporter's own bucket: head-object on the first key returns 337 bytes, on the second a 404. All three of their affected tasks now read `completed`, exit 0, with matching run_id. Present since v0.117.0, not v0.121.0 as reported: both halves — the prefix gaining the task id and these builders appending it — arrived in the same commit (#658), so neither looked wrong on its own. That also explains why records written by older spawn versions were unreadable: the reader changed, not the writer. The second defect the report could not see: clearStaleCompletion uses the same builders, so the pre-launch clear had been deleting keys that do not exist. Deleting an absent key is a no-op success in S3, so it reported success and removed nothing — #608's stale-record guard has been inert since v0.117.0. Fixing only the read would have resurrected that bug, where a previous attempt's record answers this run. The task id is no longer a parameter to any of these builders, and clearStaleCompletion lost its vestigial taskID too. That parameter was the actual hazard: two plausible things to pass, no compiler or vet complaint for passing the wrong one. An existing test caught my first attempt leaving it in place, which is the best argument for removing it rather than documenting it. The gate is a ROUND-TRIP: the key the reader computes must equal the URI the writer prints, across the default bucket, a custom results_prefix, a bare bucket, and a trailing slash. Asserting completionKey returns some expected string would not have caught this, because the builder was self-consistent — only comparing it against the writer's own path reveals the disagreement. Confirmed to fail against the shipped behaviour, printing both URIs side by side. Also updated TestClearStaleCompletion_DeletesBothKeys, which passed a bare "tasks" prefix and so encoded a calling convention no caller used — the ambiguity that produced this bug in the first place.
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 #646.
The asymmetry
outputs[].destinationwas always fully caller-controlled — per object, to any bucket, with the launch role's inline policy built from whatever the spec names. Butcompletion.json,.exitcodeandcommand.logalways landed ats3://spawn-results-<account>-<region>/tasks/<task_id>/:resultsBucketwas computed from the account and region with no flag or env var. So a consumer wanting its own layout read two places — its own prefix for results, and the fixed spawn path for the terminal signal.results_prefixon the TaskSpec collapses that to one. Omitting it is byte-identical to before, which matters because six workflow adapters poll the default path literally.Three things beyond the issue
1.
spawn task statusneeded a flag, or this would have broken it. It's given a task id, not a spec, so it cannot infer aresults_prefixthe spec set — setting one would have madetask statuslook in the wrong place.--results-prefixfixes that; without it status stays on spawn's default, where every existing task's records are.2. spawn must not create a bucket you named. It creates its own default bucket before launch so a first-ever task can't hit
NoSuchBucket. For a caller-supplied bucket, a missing one is now an error: creating it would mean a typo leaves a stray bucket behind and the run still reports success — the opposite of what someone pointing at their own storage expects.IsDefaultResultsBucketgates that, and its test pins the near-misses (right account/wrong region, right region/wrong account).3. The prefix is resolved once, by the caller. Previously the wrapper, the flush hook (#632) and the policy each derived it from a bucket name — which is how a future override reaches one and misses another, the same shape as #625's grant gap. All three now take the resolved prefix, and the pooled worker resolves it identically.
SplitS3URIrejects anything that isn'ts3://bucket/...rather than treating a typo'd scheme as a bucket name.On the argument against
I filed this with a counterargument — that a fixed, well-known location has real virtue, since
completion.jsonis the one object guaranteed to appear even when the workload never gets far enough to write a result, and since #632 it's written when a lifecycle limit kills the task mid-command too. That still holds. The resolution is that the default is unchanged, so anyone who wants the guarantee of an unambiguous path keeps it by doing nothing; the override is for a consumer that has already decided it owns the layout.Verification
Full suite,
go vet,gofmt, andmake check-docs(the new flag regenerateddocs-gen/) all pass. The 47 existing test call sites keep naming a bucket, via three test-local shims that translate to the prefix the old signature would have derived — the assertions read better that way and the shims document the change.