Skip to content

fix(pool): scoped worker IAM profile with SQS + S3 (#70) - #467

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/70-pool-worker-sqs-iam
Jul 31, 2026
Merged

fix(pool): scoped worker IAM profile with SQS + S3 (#70)#467
scttfrdmn merged 1 commit into
mainfrom
fix/70-pool-worker-sqs-iam

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

The root cause behind "pool stalls with the queue full" — found by the third real-AWS smoke.

Symptom

Workers booted, installed spored (v0.96.1/.2 fixes worked), but the queue stayed at "4 waiting" and no task ran. SSM showed the worker exited with:

Error: open pool queue: resolve queue spawn-pool-<run>: not visible after 10 attempts: ... NonExistentQueue: The specified queue does not exist or you do not have access to it.

The queue existed (submitter created it, get-queue-url from operator creds resolved it).

Root cause

spawn pool create gave workers the bare shared spored-instance-role (SSM + binary-download + spored-policy) — no SQS permissions at all. SQS masks access-denied as NonExistentQueue, so the worker's GetQueueUrl "couldn't find" a queue it simply wasn't allowed to see. (This also means #464's OpenQueue retry was looping on a permission error — correct for a real consistency race, but not the cure here.)

Fix

Workers now get a scoped instance profile via CreateOrGetInstanceProfile (the same mechanism spawn task run uses), granting exactly:

  • SQS on THIS run's queue only (ARN-scoped to spawn-pool-<runID>): GetQueueUrl / ReceiveMessage / DeleteMessage / GetQueueAttributes.
  • S3: read spawn-binaries-* (spored bootstrap download) + read/write the spec/results bucket (fetch staged specs; write completion.json/.exitcode).

CreateOrGetInstanceProfile also guarantees SSM. New test asserts the policy is valid JSON, SQS is scoped to the run queue (never *), and the buckets are granted.

Known limitation (documented, follow-up)

A task's OWN input/output buckets beyond the results bucket aren't known at pool-create and aren't granted. The common nf-spawn case keeps work in the results/work bucket; broader per-task bucket grants are a follow-up.

On the smoke-loop

This is the 4th bug a paid smoke surfaced (MissingParameter → checksum → boot-race → IAM). I audited the worker's full happy-path requirements this pass (SQS verbs + S3 buckets for bootstrap/spec/results) rather than fixing one call, so the next smoke should get materially further. go build, cmd gates, and the new policy test pass.

Refs #70.

Pool workers used the bare spored role (no SQS), so GetQueueUrl returned
NonExistentQueue (access-denied masked as not-found) and workers never pulled.
Found by a real-AWS smoke. Workers now get a scoped instance profile granting
SQS on the run queue + S3 on the spec/results + spawn-binaries buckets, like
spawn task run.
@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/pool.go 62.50% 9 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit a395a53 into main Jul 31, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/70-pool-worker-sqs-iam branch July 31, 2026 05:34
scttfrdmn added a commit that referenced this pull request Jul 31, 2026
Scoped worker IAM profile with SQS + S3 access (#70/#467).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant