Skip to content

fix(config): compute profile defaults to the caller's own credentials, not spore-host-dev (#1538) - #1539

Merged
scttfrdmn merged 3 commits into
mainfrom
fix/1538-compute-profile-default
Nov 6, 2026
Merged

scttfrdmn merged 3 commits into
mainfrom
fix/1538-compute-profile-default

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1538

What was wrong

pkg/config.GetComputeProfile() returned the hardcoded profile name "spore-host-dev" whenever SPAWN_COMPUTE_PROFILE was unset. Every LoadComputeAWSConfig caller therefore ignored --profile / AWS_PROFILE and acted in whatever account a local profile of that name pointed at. Found live: with AWS_PROFILE=aws (942542972736), #1536's role check passed against 435415984226, and the orchestrator launched two instances there.

The fix

Precedence (compute account)

# Source Example Resolved profile
1 SPAWN_COMPUTE_PROFILE non-empty SPAWN_COMPUTE_PROFILE=x x (override)
– SPAWN_COMPUTE_PROFILE="" (set, empty) skips 2, goes to 3 (the existing "empty means shared/ambient" rule)
2 compute_profile under defaults: in ~/.spawn/config.yaml (new; spawn defaults set compute-profile <name>) compute_profile: spore-host-dev that profile (override)
3a --profile --profile p p
3b SPORE_PROFILE that profile
3c AWS_PROFILE AWS_PROFILE=aws aws
3d profile = in ~/.config/spore/config.toml that profile
4 nothing "", the ambient default chain

Layer 3 is SharedProfile(), unchanged. Nothing resolves to spore-host-dev unless something names it. GetInfraProfile and its spore-host-infra default are unchanged.

Visibility. Before a detached sweep (or spawn resume --detach) creates anything, it prints:
🏦 Members launch in account 123456789012 (profile aws, from AWS_PROFILE)

Safety net. When an override (env or config) names a profile other than the caller's own, LoadComputeAWSConfig compares the two accounts. If they differ, or either can't be determined, it prints one notice per process naming both accounts, both sources, and what to unset. It never refuses. With no override it makes no extra STS call. It lives at the root, so every compute command gets it.

Members' resources follow them. On the detached path, what the members depend on is now looked up and created in the compute account through a new newComputeClient: the CLI IAM flags' role, AMI and key-pair seeding, subnet checks, spored-instance-profile and the egress-proxy find-or-create. Before this they used the caller's credentials even when the members launched elsewhere. spawn resume --detach does the same for its re-checks and its profile re-creation. With no override the two accounts are the same, so behaviour is unchanged.

Call-site audit

Call site Use Verdict
cmd/launch_sweep_dispatch.go requireDetachedSweepRole (#1536) SpawnSweepCrossAccountRole check for the account members launch in Now the caller's account by default, the same account launchSweepDetached records. Prints the member-account line. Tested by signing key.
cmd/launch_sweep.go launchSweepDetached (devCfg) AWSAccountID in the orchestration record, which the orchestrator launches in Correct. Same resolution as the role check.
cmd/launch_sweep.go detached IAM client + regionClient (now newComputeClient) CLI IAM role, AMI/key seeding, subnet checks, instance profile, egress proxy find-or-create Changed from caller credentials to compute. Tested: with compute_profile set, DescribeImages/GetRole/CreateRole are signed by the compute profile.
cmd/resume.go resumeSweepDetached role check against the record's account; recheck and profile re-create Role check is unchanged (it still skips and warns when the record's account differs). Recheck and profile now use the compute client. Prints the member-account line, naming the record's account when it differs.
cmd/schedule.go:231 computeAccountID recorded for the scheduled sweep's orchestrator Correct. The caller's account by default (it was the team dev account).
cmd/launch_batchqueue.go:104 staging bucket and account for the queue config Correct by default. See the finding below for the override case.
cmd/queue.go:223 (queue status) DescribeInstances Correct by default. Now the same account the instance was launched with.
cmd/queue.go:342 (queue results) S3 download Correct.
cmd/collect.go resultsReaderConfig (via collectComputeConfig) reads spawn-results-<acct>-* and checks the record's account Correct. The error message now names the resolved source and both ways to fix it.
lambda/* — None. No Lambda module calls GetComputeProfile, LoadComputeAWSConfig or ResolveComputeProfile. A Lambda has no SPAWN_COMPUTE_PROFILE, no ~/.spawn/config.yaml and no AWS_PROFILE, so nothing changes there. All 8 nested Lambda modules pass.

Other hardcoded "spore-host-dev" values

  • test/e2e/helpers.go and test/e2e/reaper.go: the real-AWS e2e harness fell back to spore-host-dev without exporting it. After this fix that would have let the binary launch in the ambient account while the harness and reaper looked in dev, which is a leak risk. The fallback now lives in one place (e2eProfile), and spawnChildEnv exports it to the binary as AWS_PROFILE. This entry is allowlisted.
  • pkg/testutil/integration_helpers.go (//go:build integration, not in the binary): allowlisted.
  • Comments and prose updated: cmd/launch_sweep.go ("IMPORTANT: Always use spore-host-dev profile"), cmd/launch_batchqueue.go, pkg/config/shared.go, test/e2e/substrate_cli.go.

Finding, not changed: --batch-queue with an override. The queue config is staged through the compute config, but the queue instance launches with aws.NewClientWithRegion (the caller's credentials). With a split override the bucket and the instance are in different accounts. The same was true before this PR for anyone whose AWS_PROFILE wasn't spore-host-dev. It's a foreground launch, so I left it on the caller's credentials. spawn queue status has the matching issue: it describes with compute credentials an instance launched with the caller's.

Infra default: in the audited paths, no compute-side write goes through the infra config. Params upload, the orchestration record and schedules are infra by design.

Migration (owner's setup relies on the old default)

Anyone who relied on the implicit spore-host-dev compute profile must set it once:

spawn defaults set compute-profile spore-host-dev
# writes to ~/.spawn/config.yaml:
# defaults:
#   compute_profile: spore-host-dev

Or export SPAWN_COMPUTE_PROFILE=spore-host-dev. The spore.host team's own split setup relies on this. Without it, compute follows your AWS_PROFILE or default credentials.

Tests

  • pkg/config/compute_profile_test.go: a hermetic precedence table over a fake AWS config with one profile and access key per layer, plus spore-host-dev defined so a regression resolves real credentials. Cases cover env set, env empty (skips config), config key, AWS_PROFILE only, --profile, SPORE_PROFILE, the spore config file, nothing (ambient), and asking for spore-host-dev by name. Each case asserts the profile, the source, override, and the access key LoadComputeAWSConfig hands out. Notice tests: config override in another account, env override, same account (no notice), no override (zero lookups), override equal to own profile. Plus spawn defaults set/unset compute-profile.
  • cmd/launch_sweep_compute_account_test.go uses fix(sweep): honour --detach without --max-concurrent; decide the sweep path once (#1535) #1536's seams (sweepRoleIAM, the recording AWS fake, which now also records signing keys) and withLogDir(t, false). With AWS_PROFILE alone, the role check is signed by the caller and nothing is created. compute_profile moves the role check. Past the role check every request uses the compute account. With compute_profile set, member-resource calls are signed by the compute profile.
  • compute_profile_default_test.go: an AST source gate. No non-test Go file may have a string literal (or + run) whose value is spore-host-dev, except the two allowlist entries, each with a reason. A stale allowlist entry also fails.

Revert evidence

  • Restoring return "spore-host-dev" as the fallback fails the precedence cases AWS_PROFILE only, --profile, SPORE_PROFILE, spore config file and nothing at all, plus no override costs nothing and TestComputeProfileDefaultKey. It fails both cmd tests (role check signed with AKIDTEAMDEV) and the source gate (endpoints.go:112: "spore-host-dev" as a value).
  • Reverting the detached regionClient / IAM client to aws.NewClient* fails TestDetachedSweepMemberResourcesFollowComputeProfile (DescribeImages/GetRole/CreateRole signed with AKIDCALLER) and TestDetachedSweepLaunchUsesTheComputeAccount (newComputeClient handed out 0 client(s)).

Checks run: make check; full go test ./... with AWS env stripped; all 8 nested Lambda modules; make test-e2e-tier0; semgrep scan --config=auto --error . (clean); make cli-iam-actions (no change); make api-snapshot (no change); make gen-docs (docs-gen/defaults.md committed).

Live-test checklist (not run: no AWS access in this change)

  • AWS_PROFILE=aws alone (no SPAWN_COMPUTE_PROFILE, no compute_profile): spawn launch mr --param-file p.yaml --sweep-name mr prints Members launch in account 942542972736 (profile aws, from AWS_PROFILE) and is refused by fix(sweep): honour --detach without --max-concurrent; decide the sweep path once (#1535) #1536's role check ("needs SpawnSweepCrossAccountRole in account 942542972736 … Nothing was created"). Then confirm nothing was created in either account: no orchestration record for the sweep id in spawn-sweep-orchestration, no params object, no spawn-instance-* role, no instances in 435415984226 or 942542972736.
  • Owner's setup after spawn defaults set compute-profile spore-host-dev: a small detached sweep (t4g.small, ttl) prints Members launch in account 435415984226 (profile spore-host-dev, from compute_profile in ~/.spawn/config.yaml). If ambient creds are another account, it also prints the override notice. Members launch in 435415984226. Terminate and verify.
  • SPAWN_COMPUTE_PROFILE=aws (the issue's control) is still refused the same way.
  • SPAWN_COMPUTE_PROFILE="" with compute_profile set: compute follows AWS_PROFILE, so the config is skipped.
  • spawn collect-results on an existing dev-account sweep with compute_profile: spore-host-dev reads the results. Without it, and with AWS_PROFILE for another account, it fails with the new message naming the source.

@scttfrdmn

Copy link
Copy Markdown
Contributor Author

Live test at 9153c669: PASS

Check Result
AWS_PROFILE=aws alone (no SPAWN_COMPUTE_PROFILE; the owner's ~/.spawn/config.yaml has no compute_profile), default detached sweep mr4 Printed 🏦 Members launch in account 942542972736 (profile aws, from AWS_PROFILE), then refused: a detached sweep needs SpawnSweepCrossAccountRole in account 942542972736 … Nothing was created. Exit 1. I verified nothing was created: no spawn-sweep-orchestration record, 0 params objects, no IAM role created in the last 20 min, and running-instance counts unchanged in both 942542972736 and 435415984226. On main, this same command launched 2 members in 435415984226 (#1538).
AWS_PROFILE=aws SPAWN_COMPUTE_PROFILE=spore-host-dev, sweep ov1 Override notice: ⚠️ Compute operations use account 435415984226 (profile spore-host-dev, from SPAWN_COMPUTE_PROFILE), not your own credentials' account 942542972736 (profile aws, from AWS_PROFILE). Instances launch there. Unset SPAWN_COMPUTE_PROFILE to use your own account. Then 🏦 Members launch in account 435415984226 …. 2 members in 435415984226, 0 in 942542972736. COMPLETED 2/2, and both members terminated on completion.

Not run live: the compute_profile config key and SPAWN_COMPUTE_PROFILE="". I deliberately didn't touch the owner's ~/.spawn/config.yaml, so these rely on unit tests. collect-results wasn't run live either.

Owner migration, still to do after this ships: run spawn defaults set compute-profile spore-host-dev, or export SPAWN_COMPUTE_PROFILE=spore-host-dev.

@codecov

codecov Bot commented Nov 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.27451% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/config/compute_notice.go 85.71% 6 Missing ⚠️
cmd/resume.go 0.00% 3 Missing ⚠️
pkg/config/endpoints.go 86.95% 3 Missing ⚠️
cmd/launch_sweep.go 75.00% 1 Missing ⚠️
cmd/launch_sweep_dispatch.go 90.90% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit d5255b8 into main Nov 6, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1538-compute-profile-default branch November 6, 2026 05:47
@scttfrdmn scttfrdmn mentioned this pull request Nov 6, 2026
4 tasks
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.

Detached sweeps ignore AWS_PROFILE: compute profile defaults to the hardcoded 'spore-host-dev'

1 participant