Repository navigation
fix(sweep): honour --s3-read/--s3-write, via one IAM predicate shared with the single path - #695
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… with the single path #539 was "the sweep path accepts the IAM flags, never reads them, never warns" — every row fell back to spored-instance-role, whose fixed policy grants S3 only on spawn's own buckets, so a workload reading the caller's bucket booted, billed and died on 403. That was fixed for the flags which existed then. #614 later added --s3-read/--s3-write to the single-instance condition and not to the sweep one, so those two kept the original behaviour — the same bug, re-created in the same place, because the condition was duplicated rather than shared. Both paths now call cliIAMFlagsRequireCustomProfile(), and the sweep path builds the same scoped policy via taskStagingPolicy. A gate asserts neither path re-spells the condition inline — and it matches a CALL SITE, because matching the bare name passed vacuously against the file that holds the definition. Fixes #539
scttfrdmn
force-pushed
the
fix/539-sweep-s3-iam
branch
from
October 4, 2026 23:34
5330d29 to
e87c2d5
Compare
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 #539. Your trace was exact — and the fix for it has been in the tree for a while, which is how I found the part that is still broken.
What I found
applyCLIIAMToSweepexists and its doc comment cites #539, so--iam-role,--iam-policy,--iam-policy-fileand--iam-role-tagsdo reach sweep rows now, folded intoparamFormat.Defaults["iam_role"]exactly as you'd expect.But its trigger condition was:
and the single-instance condition was:
--s3-readand--s3-writeappear in one and not the other. #614 added them to the single-instance path after #539's fix landed, so on a sweep they still do exactly what you reported: accepted, never read, never warned, falls back tospored-instance-role, 403 on the firstaws s3call after paying for the boot.grep s3ReadBuckets cmd/launch_sweep.goreturned nothing at all.So this is your bug, re-created in the same function, for the two newest flags — because the condition was duplicated rather than shared. That is the thing I fixed, not just the two flags.
The fix
One predicate,
cliIAMFlagsRequireCustomProfile(), called by both paths. A flag listed there is honoured everywhere or nowhere, and a new IAM-ish flag has exactly one place to be added.The sweep path also now builds the scoped bucket policy through the same
taskStagingPolicythe single-instance and task paths use, with the samevalidateS3BucketFlagspre-check. Deciding "a custom profile is needed" is not sufficient on its own — without the inline policy the role still has no grant on the caller's buckets and every row 403s anyway.Your observation that the param-file
iam_role:key works and is the usable workaround stays true, and a row's owniam_role:still wins over the CLI flag.On the gate, and a mistake worth recording
The class gate asserts neither path re-spells the condition inline. My first version searched each file for the bare string
cliIAMFlagsRequireCustomProfile()— and passed with the drifted condition deliberately restored, because the function is defined inlaunch_sweep.go, so that file matched its own declaration. It now matches a call site (if [!]cliIAMFlagsRequireCustomProfile()), and fails correctly when I revert the sweep condition.That is the fourth test I have written today that could not fail, all with one root cause: the assertion was satisfied for a reason other than the one intended. The others were #684's region-substitution test (which set the field no caller set), a
Contains(usage, "or")check that matched the "or" inside "spore", and a stream-routing test whose annotations were all empty strings. I am now reverting the fix and watching the test fail before I believe any of them.Gates
gofmt -lempty,go vet ./...,go test -short ./...,make check-docs, changelog gate,semgrep→ 0 findings. Seven-case table test over every IAM flag, plus the two structural gates, each confirmed to fail when the drift is reintroduced.Not hardware-verified. The predicate and policy construction are pure, but "a sweep row can now read the caller's bucket" is an IAM authorization claim, and
make smoke-neededflagspkg/aws/iam.go-adjacent work as hardware-sensitive — a one-row sweep with--s3-readagainst a real bucket would settle it, and is worth doing before the next tag.