Skip to content

Give the pipeline stage runner's AWS clients the instance's region (#906) - #915

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/906
Oct 15, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/906

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #906.

What

pkg/pipeline built six AWS configs with a bare LoadDefaultConfig(ctx): NewStageDataHandler, DownloadResultsToLocal, GeneratePeerDiscoveryFile, NewStageRunner, downloadPipelineDefinitionFromS3 and IsPipelineInstance. On an EC2 instance nothing ambient names a region, and the SDK reads one from IMDS only when asked. So the S3 and EC2 clients the stage runner builds would fail with Missing Region, the same defect #899/#902 fixed in the queue runner. (NewStageRunner and IsPipelineInstance already overwrote cfg.Region from the identity document. The other four did not.)

All six now go through one helper, loadAWSConfig in pkg/pipeline/awsconfig.go: LoadDefaultConfig(ctx, WithEC2IMDSRegion()). IMDS is consulted only when no AWS_REGION or profile region is set, so an explicit region still wins. Off EC2 with no region configured, the IMDS lookup fails and the config comes back regionless, as before.

This is dead code

spored run-pipeline-stage is the only caller of any of these functions, and nothing invokes it:

  • No reference anywhere in this repo except its definition and cmd/spored/cli_test.go's subcommand list. None in any sibling repo under spore-host.
  • The live spawn pipeline launch → spawn-pipeline-orchestrator Lambda path writes stage user data that downloads spored but never runs it. It runs the stage command in bash and writes the markers with the AWS CLI.
  • Even if it were invoked, it would fail: loadStageInfoFromTags requires spawn:s3-config-key, which the orchestrator never sets.

So the fix is latent and deliberately minimal. Nothing is deleted. #910 proposes removing the stage runner or wiring it into the orchestrator.

Tests (pkg/pipeline/awsconfig_test.go)

These use a fake IMDSv2 server, as in #902, with every ambient region source cleared:

  • TestLoadAWSConfig_TakesTheInstanceRegionFromIMDS: the helper resolves us-west-2 from IMDS.
  • TestLoadAWSConfig_AmbientRegionBeatsIMDS: AWS_REGION still wins.
  • TestNewStageDataHandler_TakesTheInstanceRegionFromIMDS: checks the region on the S3 client the constructor actually builds.
  • TestEveryPipelineAWSConfigGoesThroughLoadAWSConfig: an AST gate. It fails on any call to LoadDefaultConfig in a non-test pkg/pipeline file outside loadAWSConfig. It matches the call through whatever alias the config package is imported under, so comments don't count. It fails if discovery finds no call at all.

Each gate was run against a revert that compiles (go vet clean) and failed:

  • Helper without WithEC2IMDSRegion: the IMDS test and the data-handler test fail with region = "".
  • downloadPipelineDefinitionFromS3 back to config.LoadDefaultConfig: the AST gate fails at stage_runner.go:256.
  • NewStageDataHandler back to awsconfig.LoadDefaultConfig: the AST gate and the data-handler test both fail.

make check passes apart from the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested passes (all 9 modules). No public-surface change: pkg/pipeline is not on the surface and the helper is unexported. No AWS resources were created.

Related bugs found and filed

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 37.50000% with 5 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/pipeline/stage_runner.go 0.00% 3 Missing ⚠️
pkg/pipeline/data_handoff.go 50.00% 1 Missing ⚠️
pkg/pipeline/peer_discovery.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

)

pkg/pipeline built six AWS configs with a bare LoadDefaultConfig. On an
instance that names no region, since the SDK reads it from IMDS only when
asked, so `spored run-pipeline-stage`'s S3 and EC2 calls would fail with
"Missing Region": the same defect #899 fixed in the queue runner. They
now share loadAWSConfig, which adds WithEC2IMDSRegion, so an explicit
region still wins.

Nothing invokes run-pipeline-stage today. The orchestrator's stage user
data runs the command itself, and doesn't set the tags the runner needs.
So this fix is latent and kept minimal. #910 proposes removing or wiring
the runner.

Tests: a fake IMDSv2 server checks the helper and NewStageDataHandler's
S3 client, and an AST gate fails on any LoadDefaultConfig call in
pkg/pipeline outside the helper.
The fake IMDS server writes its identity document through a JSON encoder
instead of concatenating it into a raw ResponseWriter write, and the MPI
harness runs rank 0's block from a script file rather than bash -c.
@scttfrdmn
scttfrdmn merged commit 24892d6 into main Oct 15, 2026
10 of 11 checks passed
@scttfrdmn
scttfrdmn deleted the fix/906 branch October 15, 2026 19:30
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.

pkg/pipeline: AWS clients built without a region fail on instances (same class as #899)

1 participant