Skip to content

Give spawn burst instances credentials, tags and a TTL (#905) - #926

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/905
Oct 15, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/905

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Problem

spawn burst built its own RunInstancesInput (cmd/burst.go). Compared with the spawn launch path, it was missing:

The spored role also had no access to spawn-hybrid-registry, so no job-array member could register (burst or spawn launch --array).

Fix

  • Instance profile: burst resolves it the way spawn launch does with no --iam-* flags, through SetupSporedIAMRole, which creates or reuses spored-instance-profile. --instance-profile <name> uses an existing profile with no IAM calls, like spawn launch --instance-profile (launch attaches an instance profile with no access to the workload's bucket, and the failure surfaces minutes later as a 403 on a paid instance #550). Burst does not get the --iam-role/--iam-policy family. The guard is where the member configs are built, so burst refuses to launch with no profile.
  • Shared launch path: burst calls pkg/aws Client.Launch once per member, the same call spawn launch uses. buildTags writes spawn:managed, spawn:launch-time, spawn:ttl, spawn:ttl-deadline, spawn:on-complete=terminate and spawn:job-array-{id,name,size,index}. Members also get the launch path's network interface, block-device and volume-tag handling.
  • spawn:burst=true is passed as a burst-only custom tag (LaunchConfig.Tags). buildTags never writes it, so spawn launch members still never carry it (Register only hybrid job-array members with the hybrid registry (#904) #920's TestBuildTags_JobArrayMemberIsNotTaggedBurst).
  • --ttl, default 8h, plus --idle-timeout. The TTL must parse with time.ParseDuration, because buildTags computes the deadline that way. Burst rejects a TTL that is empty, unparseable (1d) or not positive before it creates anything. Otherwise a member would get spawn:ttl with no deadline.
  • User-data is gzip+base64 encoded with launcher.EncodeLinuxUserData.
  • --job-array-name defaults to the job-array ID. If a launch fails part-way, burst lists the members already running and the spawn array cancel command for them.

Why the registry grant, and why this narrow

Every spored on an instance tagged spawn:job-array-id calls registry.Register, and burst exists so cloud members can join a registry-coordinated array. Neither spored policy granted anything on the table. Both now carry one statement:

  • Actions: dynamodb:PutItem, UpdateItem, DeleteItem and Query. These are exactly the calls pkg/registry.PeerRegistry makes (Register, Heartbeat, Deregister, DiscoverPeers). No Scan, no batch calls, no table management. EnsureTable runs on the workstation with the user's own credentials.
  • Resource: arn:aws:dynamodb:*:${aws:PrincipalAccount}:table/spawn-hybrid-registry. That is one table, in the instance's own account, with no index wildcard. The policy variable lets the static sporedDCVRolePolicy, used by SetupSporedIAMRole, carry the same statement as the dynamic baseline.
  • Why not narrower: the policy cannot limit a member to its own items, because the partition key is the job-array ID and the policy cannot know it. This grant is still much smaller than what the role already has, which can terminate any spawn-managed instance in the account.
  • Rollout: SetupSporedIAMRole re-puts the inline policy on every launch, and the baseline is re-ensured on custom roles, so existing roles get the grant on their next launch. This is not the infra account's control plane, so nothing under lambda/ or deployment/ changes.

The other half of the registry problem, that the client had no region on EC2, is #899 / PR #902. This PR does not touch pkg/registry.

Tests

Each test was watched failing against a revert that compiles:

Revert Fails
member IamInstanceProfile: "" TestBurstLaunchAttachesTheInstanceProfile
profile guard → if false && … TestBurstLaunchRefusesWithoutAnInstanceProfile
member TTL: "" TestBurstMembersHaveATTL
validateBurstParams returns nil before the TTL checks TestBurstRejectsTTLsWithNoDeadline
JobArrayIndex: 0 TestBurstMembersAreDistinctJobArrayMembers
burst tag key → spawn:burst-x TestBurstMembersAreTaggedBurst
raw user-data TestBurstUserDataIsBase64
partial failure returns nil IDs TestBurstPartialFailureReturnsTheLaunchedIDs
defaultBurstTTL = "" six burst tests
registry statement dropped from the dynamic baseline TestBothSporedPolicyPathsGrantTheHybridRegistry/dynamic…
registry statement replaced in the static policy TestBothSporedPolicyPathsGrantTheHybridRegistry/static…
dynamodb:Scan added to the grant TestHybridRegistryGrantIsNarrow
buildTags job-array index → 0 TestBuildTags_BurstMemberIsReaperVisibleAndBounded

The registry tests discover the action set from pkg/registry/dynamodb.go (r.client.<Op>( calls) and read the table name from its TableName constant, so the grant cannot drift from the client. If discovery finds nothing, the tests fail. A compile-time assertion pins *aws.Client as burst's launcher.

make check passes except TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, which needs Docker. All 9 nested modules pass. The public surface is unchanged: everything new in pkg/aws is unexported. docs-gen/burst.md is regenerated. No AWS resources were created and no instances were launched.

Conflicts with #920

#920 adds cmd/burst_tags_test.go, which calls launchBurstInstances with an *ec2.Client against Substrate. After this PR, launchBurstInstances takes a burstLauncher (*aws.Client) and needs an instance profile and TTL, so that test will not compile once both PRs are merged. TestBurstMembersAreTaggedBurst here covers the same assertion, so whichever PR merges second should drop or adapt that file. The CHANGELOG [Unreleased] entries may also need a trivial merge.

Filed separately

Fixes #905
Fixes #917

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.28070% with 43 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/burst.go 59.00% 39 Missing and 2 partials ⚠️
pkg/aws/iam.go 85.71% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

spawn burst launched its members with no IAM instance profile, five
hand-written tags, no TTL and unencoded user-data. RunInstances rejected the
user-data, so every burst failed. Had it not, the members would have had no
credentials for spored, no spawn:managed tag (so the TTL reaper, spawn list and
the spored role's terminate grant could not reach them), no deadline, and the
same job-array index on every member.

Burst now resolves the instance profile the way spawn launch does with no
--iam-* flags (SetupSporedIAMRole, or --instance-profile to skip it). It
launches each member through pkg/aws Client.Launch, so buildTags writes the
same tags a spawn launch job-array member gets, with a per-member index and a
TTL (--ttl, default 8h; must parse as a Go duration so the deadline is
computed). spawn:burst=true is added as a burst-only custom tag, never by
buildTags (#904). --job-array-name defaults to the ID so the printed spawn
array status hint finds the members.

Both spored policies now grant PutItem/UpdateItem/DeleteItem/Query on
spawn-hybrid-registry in the caller's own account, which is what the
in-instance registry client calls. Without that, no job-array member could
register.

Fixes #917.
…ent.Launch, and TestBurstMembersAreTaggedBurst covers the same assertion (#905)
@scttfrdmn
scttfrdmn merged commit f8ea58f into main Oct 15, 2026
7 checks passed
@scttfrdmn
scttfrdmn deleted the fix/905 branch October 15, 2026 21:52
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