Skip to content

Make spawn burst and every other command honour --region and --profile (#939) - #966

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/939
Oct 17, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/939

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #939
Fixes #963

Stacked on #940 (fix/924, on #934, on #926). Review after those; the diff here is only this branch.

What was wrong

spawn burst built its AWS config with a bare config.LoadDefaultConfig(ctx), and so did registry.EnsureTable. Nothing on the burst path read the root's --region / --profile (recorded by spawnconfig.SetSharedFlags) or SPORE_REGION. The AMI lookup, the registry table and every member went wherever the ambient chain pointed.

The fix

  • cmd/awsconfig.go: loadAWSConfig(ctx, region), a wrapper over spawnaws.NewClientWithRegion. That is the resolution spawn launch uses since spawn launch --region ignored; ambient AWS_REGION/resolution wins → instance in wrong region #276: explicit region, then the shared spore config (--region, SPORE_REGION, AWS_REGION, config.toml), then the SDK default chain, with the shared profile.
  • Burst loads one config through it and uses it for the AMI check, EnsureTable(ctx, cfg) and the members. It refuses to start with no region.
  • registry.EnsureTable now takes an aws.Config. pkg/registry is not public surface, so the snapshot does not change.

The gate

TestCommandsLoadAWSConfigThroughTheSharedLoader parses every non-test file in package cmd, with no list, and fails on any call to github.com/aws/aws-sdk-go-v2/config.LoadDefaultConfig. The call is matched by resolved import path, so awsconfig./sdkcfg. aliases are caught and comments are not (TestBareSDKConfigLoadsMatchesTheCallUnderAnyName covers the matcher). WithRegion does not exempt a call, because it still ignores --profile. If the package has no files, the test fails.

On its first run it found 22 more sites: bot (8), cancel (2, including the sweep instance terminate), completion, cost, extend, fsx (3), onboard (whose help says "run with credentials for the account... profile"), service and sweep dry-run pricing, team (2) and validate. All of them now go through loadAWSConfig. With no flag and no SPORE_* set, they resolve exactly as before.

Also: #963

registry.NewPeerRegistry is the client spored registers and heartbeats through. It also used a bare default config. On EC2 that config has no region: the unit sets no AWS_REGION, and the SDK does not read the region from IMDS. So Register failed and burst members never appeared in the registry their local nodes read. It now uses identity.Region.

Tests (no AWS, nothing launched)

  • TestBurstHonoursTheRegionFlag, ...SporeRegion and ...TheProfileFlag run spawn burst through the real root command with a recording HTTPClient. Nothing reaches the network, and RunInstances gets a 403. Each test asserts that DescribeTable and RunInstances were sent, and that every regional request went to the expected region: --region beats AWS_REGION, SPORE_REGION beats AWS_REGION, and --profile takes its profile's region.
  • TestBurstRefusesToRunWithNoRegion: it makes zero AWS calls.
  • TestEnsureTableUsesTheCallersRegion, TestEnsureTableRefusesAConfigWithNoRegion, TestNewPeerRegistryUsesTheMembersRegion.

Each test was run against a revert that compiles:

  • loadAWSConfig returning a bare config.LoadDefaultConfig(ctx): all three burst tests fail, and every call goes to eu-west-1 (the ambient region).
  • EnsureTable ignoring its cfg: fails, "made no DynamoDB request".
  • NewPeerRegistry without the region: fails, region "".
  • sdkcfg.LoadDefaultConfig(ctx) (aliased import) put back in burst.go: the gate fails at burst.go:119.

make check: all packages pass except the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker. make check-nested: all 9 nested modules clean.

Caveats

#939)

spawn burst loaded its AWS config with a bare config.LoadDefaultConfig, and
registry.EnsureTable did the same, so burst ran in the ambient region whatever
--region, --profile or SPORE_REGION said: the AMI lookup, the registry table and
every member landed where AWS_REGION or the shared AWS config pointed. Same
shape as #276 (launch) and #774 (autoscale).

Burst now loads one config through cmd's loadAWSConfig, a thin wrapper over
spawnaws.NewClientWithRegion (explicit region > shared spore config > ambient,
with the shared profile), and passes it to EnsureTable, which now takes an
aws.Config. Burst refuses to run with no region at all.

The gate, TestCommandsLoadAWSConfigThroughTheSharedLoader, parses every
non-test file of package cmd and fails on any call to the SDK config package's
LoadDefaultConfig, matched by resolved import path so aliases are caught and
comments are not. Its first run found 22 more call sites in bot, cancel,
completion, cost, extend, fsx, onboard, service, sweep_pricing, team and
validate. All go through loadAWSConfig now; with no flags or SPORE_* set they
resolve exactly as before.

Also fixes #963: NewPeerRegistry, the client spored registers and heartbeats
through, used a bare default config. On EC2 that has no region (the unit sets
no AWS_REGION and the SDK does not read IMDS for it), so burst members never
registered. It now uses identity.Region.

Tests: burst run through the real root command against a recording HTTP
client (no network, RunInstances refused) for --region vs AWS_REGION,
SPORE_REGION vs AWS_REGION, and --profile's region; EnsureTable and
NewPeerRegistry region tests. Each watched failing against a compiling revert.

Fixes #939
Fixes #963

(#939)
@codecov

codecov Bot commented Oct 17, 2026

Copy link
Copy Markdown

@scttfrdmn
scttfrdmn merged commit ca1e91d into main Oct 17, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/939 branch October 17, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant