Skip to content

fix(sweep): orchestrator renders spored bootstrap and tags for v0.146.0-era params (#1368) - #1370

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1368-legacy-params-bootstrap
Oct 27, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1368-legacy-params-bootstrap

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1368

Owner decision: option 3. For legacy params, the ones with no spawn_user_data and no spawn_tags, the sweep orchestrator renders the member's spored bootstrap and its tags itself. These params come from a v0.146.0-or-older CLI, whose detachedParamKeys are ami, iam_role, instance_type, key_name, spot and ttl, or from an existing schedule, which replays the params its creating CLI uploaded. Old CLIs and existing schedules keep working on the redeployed orchestrator, and their members now run spored.

What changed

lambda/sweep-orchestrator/legacy.go (new), called first by buildRunInstancesInput:

  • Bootstrap. Rendered with launcher.BuildUserData, the shared pkg/launcher builder. Its stub fetches and verifies the body published for the orchestrator's own release (User data: fetch the bootstrap from S3 behind a small verifying stub, removing the 16 KiB ceiling (follow-up to #1246) #1274). That release is main.Version, which the deploy script injects. applyVersion() (called from init) hands it to launcher.CallerVersion, because this module replaces spawn with ../.. and a replaced spawn names no release. A build with no injected version inlines the body, like any dev build.
  • Tags. Rendered with spawnaws.BuildLaunchTags, the tag builder Client.Launch uses. Inputs are the legacy keys plus the sweep record: spawn:iam-user comes from user_id and spawn:account-id/-base36 from aws_account_id. The set includes spawn:managed, spawn:root, spawn:created-by, spawn:ttl, spawn:version (the orchestrator's), spawn:os=linux, spawn:local-username=ec2-user, Name, and the sweep id/name/index/size. The result then goes through the unchanged memberTags, which re-anchors launch-time and ttl-deadline at the real launch, sets the tags the orchestrator owns, and runs the fix(launch): refuse a launch over AWS's 50-tag limit before any AWS call (#1336) #1358 50-tag check.
  • Defaults. A member with no ttl gets the CLI's 1h sweep-member idle timeout. On Spot its idle action is terminate, since the orchestrator makes one-time requests that EC2 cannot stop. A member with no iam_role gets spored-instance-profile; see "Version and profile findings".
  • Not rendered. No spawn:price-per-hour: it needs the Price List API, which the orchestrator's role cannot call, and legacy params carry no cost limit to enforce. Other row keys are ignored, as v0.146.0's orchestrator ignored them. The bootstrap is the Linux one, since v0.146.0 did not record the member's OS.
  • Partial legacy. Params with exactly one of the two keys are refused, and the error names the member and both keys. Every spawn that writes either key writes both, so one key alone means the params are damaged, not old. Pairing a CLI's bootstrap with tags rendered here, or the reverse, would boot a member against tags it was not rendered for.
  • Strict path. Params carrying both keys go through the existing path unchanged (identity). Params without spawn_launch_settings keep fix(sweep): carry every RunInstances setting to detached sweep members, refuse the rest (#1353) #1367's legacy RunInstances path. That path's log line now reads the uploaded params, so it names the creating CLI's version, not the orchestrator's.

scripts/deploy-sweep-orchestrator.sh:

  • Refuses to deploy unless HEAD is exactly a vX.Y.Z tag and the tree is clean.
  • Checks that spawn-binaries-us-east-1/spawn/versions/<v>/bootstrap.sh exists and hashes to the body this checkout compiles in (spawn bootstrap-body).
  • Builds with -ldflags "-X main.Version=<v>", and stamps spawn:version with that same value.
  • Builds the package (.), not main.go. On main the script ran go build ... main.go, which no longer compiles now that the function has spored.go, tags.go and cancel.go, so no deploy of current main could have succeeded. deploy-scheduler-handler.sh gets the same one-word change (it is a single file today) so the new discovery gate holds for every script.

Also:

Version and profile findings

  • pkg/buildinfo / launcher.PublishedBodyVersion for a Lambda build: the main module is .../lambda/sweep-orchestrator and the spawn dependency has Replace != nil, so it resolves to "" and a plain go build would inline the body. The orchestrator therefore takes its version from the deploy script's -X main.Version (checked: the injected string is present in the linux/amd64 binary). The deploy script's release/clean/published-body checks make sure a dev build is never deployed.
  • Profile: with no iam_role, v0.146.0's orchestrator used spawnd-role (git show v0.146.0:lambda/sweep-orchestrator/main.go:749). The v0.146.0 CLI never ensured a profile on the detached path. Its seedDetachedLaunchKeys only seeds --iam-*/--instance-profile results. Legacy members now get spored-instance-profile instead, because spawnd-role's policy (setup-spawnd-iam-role.sh) has no ec2:CreateTags: spored could not write its heartbeat and Detached (Lambda-orchestrated) sweeps never verify spored on their members (#1305 follow-up) #1313 would kill the member at 5 minutes. The cross-account role can already pass spored-instance-role, so no new IAM is needed anywhere. Remaining gap, filed as Legacy detached members with no iam_role need spored-instance-profile, which a v0.146.0-only account may not have #1369: an account that only ever ran v0.146.0 detached sweeps may have spawnd-role but no spored-instance-profile, and its legacy members would fail RunInstances (a failed row, not a leak).
  • The binary grows by about 260 KB (77.99 MB to 78.24 MB unzipped, 29 MB zipped).

Gates (each watched failing against a compiling revert)

Gate Revert Result
TestV0146ParamsMemberLaunchesWithSpored: the exact v0.146.0 key set gives a stub for 0.147.0 with the body sha, plus spawn:managed=true, ttl-deadline, owner and account tags legacy branch returns params unrendered FAIL (refused, missing spawn_user_data)
same applyVersion does not assign FAIL (inline body, no SPAWN_BS_VERSION)
same BuildLaunchTags given an empty user ARN FAIL (spawn:iam-user empty)
same ttl dropped FAIL (no ttl / ttl-deadline)
TestScheduleReplayedV0146ParamsMemberLaunchesWithSpored (yaml decode, sweep.EncodeParams, json decode, mergeParams) legacy pass-through / version / ttl reverts above FAIL
TestStrictParamsAreUnchanged strict params also rendered FAIL (user data replaced, CLI spawn:version, ttl and sweep-size lost)
TestPartialParamsAreRefused partial treated as legacy FAIL (both cases launched)
TestLegacyMemberBootsSpored (#1313 satisfied because the stub runs BootstrapBody, which runs systemctl start spored) legacy pass-through / version not applied FAIL
TestV0146ParamsMemberWithoutTTLOrRole fallback profile spawnd-role / no idle default / Spot stop on idle FAIL each (the Spot revert also flips the request to persistent)
TestInitHandsTheVersionToTheLauncher init does not call applyVersion / applyVersion does not assign FAIL each
TestDevOrchestratorInlinesTheBody legacy pass-through FAIL
scripts: TestLambdaBuildsArePackages (discovers every go build in every script) scheduler-handler back to main.go / orchestrator back to main.go FAIL each
scripts: TestDeploySweepOrchestratorDeploysOnlyAPublishedRelease no -ldflags / body comparison disabled / dirty check disabled / --always instead of --exact-match FAIL each
iamcoverage (./internal/iamcoverage) n/a (no new AWS calls: both builders are pure) pass

GOTOOLCHAIN=go1.27.3 make check and make lint (0 issues in all 10 modules) pass, and so does semgrep scan --config=auto --error . (0 findings). make api-snapshot / make cli-iam-actions: no exported pkg symbols or CLI AWS calls changed.

Deploy order

  1. Merge and tag the release (v0.147.0). Its release workflow publishes spawn/versions/0.147.0/bootstrap.sh{,.sig,.sha256}.
  2. Redeploy spawn-sweep-orchestrator from the clean v0.147.0 tag checkout with scripts/deploy-sweep-orchestrator.sh. The script now refuses anything else, and refuses a release whose body is not published or differs from the compiled one.
  3. Role scripts: none newly required by this PR. Legacy members use profiles the cross-account role can already pass (spored-instance-role, spawn-instance-*). The setup-sweep-cross-account-role.sh re-run that Detached sweep members launch with no UserData, so spored never runs on them (#725 follow-up; blocks #1313) #1323/Detached sweeps with --iam-role/--iam-policy/--instance-profile: the orchestrator cannot pass the profile, every member is refused #1331/Dashboard: terminate and sweep cancel in a member account have no role that may do them (owner decision) #1349 already require (in each member account) still applies.
  4. scripts/hardware-sensitive.txt lists lambda/sweep-orchestrator/. Before the tag, run a smoke test of a detached sweep from a v0.146.0 CLI and of an existing schedule against the redeployed orchestrator. It is not run here (no AWS).

Not verified: anything on AWS (no live calls were made). Windows legacy members get the Linux bootstrap, so spored will not come up and #1313 ends them at 10 minutes.

….0-era params (#1368)

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.
@codecov

codecov Bot commented Oct 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@scttfrdmn
scttfrdmn merged commit 0652ee0 into main Oct 27, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1368-legacy-params-bootstrap branch October 27, 2026 06:43
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.

Redeployed sweep orchestrator refuses every sweep and schedule from a v0.146.0-or-older CLI (#1323/#1330 checks)

1 participant