Repository navigation
fix(config): compute profile defaults to the caller's own credentials, not spore-host-dev (#1538) - #1539
Merged
Conversation
Contributor
Author
Live test at
|
| 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 Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
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 #1538
What was wrong
pkg/config.GetComputeProfile()returned the hardcoded profile name"spore-host-dev"wheneverSPAWN_COMPUTE_PROFILEwas unset. EveryLoadComputeAWSConfigcaller therefore ignored--profile/AWS_PROFILEand acted in whatever account a local profile of that name pointed at. Found live: withAWS_PROFILE=aws(942542972736), #1536's role check passed against 435415984226, and the orchestrator launched two instances there.The fix
Precedence (compute account)
SPAWN_COMPUTE_PROFILEnon-emptySPAWN_COMPUTE_PROFILE=xx(override)SPAWN_COMPUTE_PROFILE=""(set, empty)compute_profileunderdefaults:in~/.spawn/config.yaml(new;spawn defaults set compute-profile <name>)compute_profile: spore-host-dev--profile--profile ppSPORE_PROFILEAWS_PROFILEAWS_PROFILE=awsawsprofile =in~/.config/spore/config.toml"", the ambient default chainLayer 3 is
SharedProfile(), unchanged. Nothing resolves tospore-host-devunless something names it.GetInfraProfileand itsspore-host-infradefault 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,
LoadComputeAWSConfigcompares 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-profileand the egress-proxy find-or-create. Before this they used the caller's credentials even when the members launched elsewhere.spawn resume --detachdoes 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
cmd/launch_sweep_dispatch.gorequireDetachedSweepRole(#1536)SpawnSweepCrossAccountRolecheck for the account members launch inlaunchSweepDetachedrecords. Prints the member-account line. Tested by signing key.cmd/launch_sweep.golaunchSweepDetached(devCfg)AWSAccountIDin the orchestration record, which the orchestrator launches incmd/launch_sweep.godetached IAM client +regionClient(nownewComputeClient)compute_profileset, DescribeImages/GetRole/CreateRole are signed by the compute profile.cmd/resume.goresumeSweepDetachedcmd/schedule.go:231computeAccountIDrecorded for the scheduled sweep's orchestratorcmd/launch_batchqueue.go:104cmd/queue.go:223(queue status)cmd/queue.go:342(queue results)cmd/collect.goresultsReaderConfig(viacollectComputeConfig)spawn-results-<acct>-*and checks the record's accountlambda/*GetComputeProfile,LoadComputeAWSConfigorResolveComputeProfile. A Lambda has noSPAWN_COMPUTE_PROFILE, no~/.spawn/config.yamland noAWS_PROFILE, so nothing changes there. All 8 nested Lambda modules pass.Other hardcoded
"spore-host-dev"valuestest/e2e/helpers.goandtest/e2e/reaper.go: the real-AWS e2e harness fell back tospore-host-devwithout 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), andspawnChildEnvexports it to the binary asAWS_PROFILE. This entry is allowlisted.pkg/testutil/integration_helpers.go(//go:build integration, not in the binary): allowlisted.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-queuewith an override. The queue config is staged through the compute config, but the queue instance launches withaws.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 whoseAWS_PROFILEwasn'tspore-host-dev. It's a foreground launch, so I left it on the caller's credentials.spawn queue statushas 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-devcompute profile must set it once:Or export
SPAWN_COMPUTE_PROFILE=spore-host-dev. The spore.host team's own split setup relies on this. Without it, compute follows yourAWS_PROFILEor 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, plusspore-host-devdefined so a regression resolves real credentials. Cases cover env set, env empty (skips config), config key,AWS_PROFILEonly,--profile,SPORE_PROFILE, the spore config file, nothing (ambient), and asking forspore-host-devby name. Each case asserts the profile, the source, override, and the access keyLoadComputeAWSConfighands out. Notice tests: config override in another account, env override, same account (no notice), no override (zero lookups), override equal to own profile. Plusspawn defaults set/unset compute-profile.cmd/launch_sweep_compute_account_test.gouses 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) andwithLogDir(t, false). WithAWS_PROFILEalone, the role check is signed by the caller and nothing is created.compute_profilemoves the role check. Past the role check every request uses the compute account. Withcompute_profileset, 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 isspore-host-dev, except the two allowlist entries, each with a reason. A stale allowlist entry also fails.Revert evidence
return "spore-host-dev"as the fallback fails the precedence casesAWS_PROFILE only,--profile,SPORE_PROFILE,spore config fileandnothing at all, plusno override costs nothingandTestComputeProfileDefaultKey. It fails both cmd tests (role check signed with AKIDTEAMDEV) and the source gate (endpoints.go:112: "spore-host-dev" as a value).regionClient/ IAM client toaws.NewClient*failsTestDetachedSweepMemberResourcesFollowComputeProfile(DescribeImages/GetRole/CreateRole signed with AKIDCALLER) andTestDetachedSweepLaunchUsesTheComputeAccount(newComputeClient handed out 0 client(s)).Checks run:
make check; fullgo 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.mdcommitted).Live-test checklist (not run: no AWS access in this change)
AWS_PROFILE=awsalone (noSPAWN_COMPUTE_PROFILE, nocompute_profile):spawn launch mr --param-file p.yaml --sweep-name mrprintsMembers 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 inspawn-sweep-orchestration, no params object, nospawn-instance-*role, no instances in 435415984226 or 942542972736.spawn defaults set compute-profile spore-host-dev: a small detached sweep (t4g.small, ttl) printsMembers 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=""withcompute_profileset: compute followsAWS_PROFILE, so the config is skipped.spawn collect-resultson an existing dev-account sweep withcompute_profile: spore-host-devreads the results. Without it, and withAWS_PROFILEfor another account, it fails with the new message naming the source.