Skip to content

fix(sweep): give detached members their tags, passable profiles and row user_data (#1330, #1331, #1327) - #1354

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1330-1331-1327-detached-sweeps
Oct 27, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1330-1331-1327-detached-sweeps

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1330
Fixes #1331
Fixes #1327

#1330: detached members get the foreground member's tags

  • pkg/aws: new LaunchTagger (Client.NewLaunchTagger, Tags, TagValues). Client.Launch now builds its tags through it as well, so there is one builder: caller identity, account name, truffle price, then buildTags (exported as BuildLaunchTags). The tagger prices each (region, type, OS) once per sweep. A missing price is reused only for a member with no cost limit, so a member that has a cost limit is still refused.
  • pkg/aws.AnchorLaunchTags re-anchors the launch instants (spawn:launch-time, spawn:ttl-deadline from spawn:ttl, a persistent Spot spawn:spot-valid-until, spawn:job-array-created) at the real launch. An unparseable spawn:ttl is an error, never a member without a deadline. buildTags takes its instant from a tagClock var so the gate can render at two instants.
  • CLI (seedDetachedBootstrap, used by spawn launch --param-file and spawn schedule create): each member is built with defaultSweepMember, which is now shared with the foreground loop (region/type fallback, <sweep>-<i> name, and the 1h idle default for a member with no ttl/idle_timeout). Its tags are rendered and shipped per row as spawn_tags (a reserved row key). A Spot member that would need a persistent request is refused. See the follow-up below.
  • Lambda: the instance and its volumes are tagged with the shipped set, anchored at now. spawn:sweep-id, spawn:sweep-name, spawn:sweep-index and spawn:managed=true are set by the Lambda. A member without spawn_tags is refused, as a member without user data already is. sweepRowLifecycleTags is gone, and the Lambda no longer reads the ttl param.
  • Long/multi-line commands: over the cap they still go in user data (fix(slurm): make slurm submit and slurm convert output launchable #1329/embeddedCommand). The gate checks that one is in the user data and not in a tag.

#1331: PassRole for spawn-created profiles; refuse the rest

  • scripts/setup-sweep-cross-account-role.sh: iam:PassRole now also covers arn:aws:iam::${ACCOUNT}:role/spawn-instance-*, still conditioned on iam:PassedToService=ec2.amazonaws.com. The pipeline orchestrator already has this grant.
  • --instance-profile NAME, --iam-role NAME, and a defaults:/row iam_role: naming anything other than spored-instance-profile, spawnd-role or spawn-instance-* are refused before applyCLIIAMToSweep creates anything (on the launch path and in spawn schedule create). The message points at --iam-policy (without --iam-role) or --no-detach. I chose refusal over a broader grant because a PassRole wide enough for arbitrary roles would let the orchestrator hand any role in the account, admin included, to an instance.

#1327: row user_data: runs

  • New LaunchConfig.CustomUserData. buildLaunchConfigFromParams stores the row's value there, not in UserData, which the foreground loop overwrote. buildUserDataForKey appends it after --user-data on the foreground, detached and resume paths. A Windows member with one is refused.

Gates, each watched failing against a compiling revert

Gate Revert Result
TestDetachedMemberTagsAreTheForegroundMembers, TestEveryDetachedMemberIsBounded, TestDetachedSpotMemberThatWouldStopIsRefused, TestSeedScheduleParams_CarriesTheTags pf.Params[i][detachedTagsKey] = … → _ = memberTags[i] all fail
same defaultSweepMember(...) → false in the seed tag mismatch, no Name, no 1h idle default
TestDetachedSpotMemberThatWouldStopIsRefused spot guard never fires fails
TestAnchorLaunchTagsMovesEveryInstant (the time-dependent set is discovered by rendering at two instants) deadline not moved / valid-until not moved fails
TestLaunchTaggerPricesEachShapeOnce memo disabled / memo reused for a cost-limited member fails
Lambda TestMemberLaunchesWithTheCLIsTags, TestMemberTTLCountsFromTheRealLaunch, TestSweepRowIsReapable no anchoring / no volume spec / owned keys not overridden / old minimal tags fails
TestSweepRowUserDataRuns config.CustomUserData = s → config.UserData = s; join dropped fails
TestDetachedPassableProfilesMatchTheGrant (reads the script's grant) + scripts TestSweepCrossAccountRoleMayPassSporedsRole spawn-instance-* removed from the script; prefix check broken fails
TestUnpassableDetachedProfileIsRefusedUpFront --instance-profile check removed; refusal call disabled (&& false, if false) on the launch path or in schedule fails

Checks

make check: every stage passes except check-build-tags, which fails the same way on unmodified main from a /private/tmp worktree. make lint reports 0 issues in all 10 modules. Also run: make check-docs, semgrep scan --config=auto --error ., make api-snapshot (additions only: LaunchTagger, NewLaunchTagger, AnchorLaunchTags, BuildLaunchTags, LaunchConfig.CustomUserData), and the lambda/sweep-orchestrator and scripts module tests.

Deploy (not done here)

  • Redeploy sweep-orchestrator. Until then a current CLI's spawn_tags are ignored by the old Lambda, and the old behaviour continues. After the redeploy, sweeps and schedules created by an older CLI are refused per member (no spawn_tags) and must be re-created.
  • Re-run scripts/setup-sweep-cross-account-role.sh in each member account (SPAWN_MEMBER_ACCOUNT=…), then do one real PutRolePolicy and simulate allow/deny before relying on it.

Follow-up: #1353. Detached members still drop every non-tag RunInstances setting (volume_size, SGs/subnet/AZ, spot_max_price, hibernation, EFA, placement, persistent Spot).

@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.94937% with 38 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_sweep.go 31.25% 11 Missing ⚠️
cmd/launch_sweep_detached_bootstrap.go 75.00% 11 Missing ⚠️
pkg/aws/launch_tags.go 80.00% 11 Missing ⚠️
cmd/schedule.go 57.14% 3 Missing ⚠️
cmd/launch_config.go 75.00% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

…ow user_data (#1330, #1331, #1327)

- #1330: the CLI renders each detached member's instance tags with the code a
  foreground launch uses (aws.LaunchTagger, now shared with Client.Launch),
  after the foreground's per-member defaults (defaultSweepMember, incl. the
  1h idle default), and ships them as spawn_tags. The orchestrator tags the
  instance and its volumes with them, re-anchored at the real launch
  (aws.AnchorLaunchTags), sets the sweep identity and spawn:managed itself,
  and refuses a member without them. A Spot member that would need a
  persistent request is refused up front.
- #1331: the cross-account role may also pass role/spawn-instance-* to EC2;
  the CLI refuses any other profile on a detached sweep or schedule before
  creating anything.
- #1327: a sweep row's user_data: runs after spored's bootstrap and
  --user-data on the foreground, detached and resume paths.

Fixes #1330
Fixes #1331
Fixes #1327
@scttfrdmn
scttfrdmn force-pushed the fix/1330-1331-1327-detached-sweeps branch from 0edbf9b to 76836e0 Compare October 27, 2026 02:47
@scttfrdmn
scttfrdmn merged commit 48fafc1 into main Oct 27, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1330-1331-1327-detached-sweeps branch October 27, 2026 03:11
scttfrdmn added a commit that referenced this pull request Oct 27, 2026
….0-era params (#1368) (#1370)

A CLI at v0.146.0 or older uploads only ami, iam_role, instance_type,
key_name, spot and ttl per member, and existing schedules replay those
params on every firing, so neither carries spawn_user_data or spawn_tags.
Since #1332/#1354 the orchestrator refused such members. It now renders
both itself with the shared builders (launcher.BuildUserData, whose stub
fetches the body published for the orchestrator's own release, and
aws.BuildLaunchTags), so those members run spored and carry the full tag
set. Strict params are unchanged; params carrying only one key are refused.

The deploy script now deploys only a clean release tag whose published
bootstrap body matches the compiled one, injects -X main.Version, and
builds the package instead of main.go alone, which no longer compiled.
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