Repository navigation
fix(sweep): orchestrator renders spored bootstrap and tags for v0.146.0-era params (#1368) - #1370
Merged
Merged
Conversation
….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 Report✅ All modified and coverable lines are covered by tests. 📢 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 #1368
Owner decision: option 3. For legacy params, the ones with no
spawn_user_dataand nospawn_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, whosedetachedParamKeysare 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 bybuildRunInstancesInput:launcher.BuildUserData, the sharedpkg/launcherbuilder. 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 ismain.Version, which the deploy script injects.applyVersion()(called frominit) hands it tolauncher.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.spawnaws.BuildLaunchTags, the tag builderClient.Launchuses. Inputs are the legacy keys plus the sweep record:spawn:iam-usercomes fromuser_idandspawn:account-id/-base36fromaws_account_id. The set includesspawn: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 unchangedmemberTags, 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.ttlgets 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 noiam_rolegetsspored-instance-profile; see "Version and profile findings".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.spawn_launch_settingskeep 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:vX.Y.Ztag and the tree is clean.spawn-binaries-us-east-1/spawn/versions/<v>/bootstrap.shexists and hashes to the body this checkout compiles in (spawn bootstrap-body).-ldflags "-X main.Version=<v>", and stampsspawn:versionwith that same value..), notmain.go. On main the script rango build ... main.go, which no longer compiles now that the function hasspored.go,tags.goandcancel.go, so no deploy of current main could have succeeded.deploy-scheduler-handler.shgets the same one-word change (it is a single file today) so the new discovery gate holds for every script.Also:
cmd/launch_sweep_detached_keys.go:ttlis back indetachedParamKeys, because the Lambda reads it again for legacy params (TestDetachedSweepSeedsEveryKeyTheLambdaReads).Version and profile findings
pkg/buildinfo/launcher.PublishedBodyVersionfor a Lambda build: the main module is.../lambda/sweep-orchestratorand the spawn dependency hasReplace != nil, so it resolves to""and a plaingo buildwould 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.iam_role, v0.146.0's orchestrator usedspawnd-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. ItsseedDetachedLaunchKeysonly seeds--iam-*/--instance-profileresults. Legacy members now getspored-instance-profileinstead, becausespawnd-role's policy (setup-spawnd-iam-role.sh) has noec2: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 passspored-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 havespawnd-rolebut nospored-instance-profile, and its legacy members would fail RunInstances (a failed row, not a leak).Gates (each watched failing against a compiling revert)
TestV0146ParamsMemberLaunchesWithSpored: the exact v0.146.0 key set gives a stub for 0.147.0 with the body sha, plusspawn:managed=true, ttl-deadline, owner and account tagsapplyVersiondoes not assignSPAWN_BS_VERSION)BuildLaunchTagsgiven an empty user ARNspawn:iam-userempty)TestScheduleReplayedV0146ParamsMemberLaunchesWithSpored(yaml decode,sweep.EncodeParams, json decode,mergeParams)TestStrictParamsAreUnchangedspawn:version, ttl and sweep-size lost)TestPartialParamsAreRefusedTestLegacyMemberBootsSpored(#1313 satisfied because the stub runsBootstrapBody, which runssystemctl start spored)TestV0146ParamsMemberWithoutTTLOrRolespawnd-role/ no idle default / Spot stop on idleTestInitHandsTheVersionToTheLauncherapplyVersion/applyVersiondoes not assignTestDevOrchestratorInlinesTheBodyscripts: TestLambdaBuildsArePackages(discovers everygo buildin every script)main.go/ orchestrator back tomain.goscripts: TestDeploySweepOrchestratorDeploysOnlyAPublishedRelease-ldflags/ body comparison disabled / dirty check disabled /--alwaysinstead of--exact-match./internal/iamcoverage)GOTOOLCHAIN=go1.27.3 make checkandmake lint(0 issues in all 10 modules) pass, and so doessemgrep scan --config=auto --error .(0 findings).make api-snapshot/make cli-iam-actions: no exported pkg symbols or CLI AWS calls changed.Deploy order
spawn/versions/0.147.0/bootstrap.sh{,.sig,.sha256}.spawn-sweep-orchestratorfrom the clean v0.147.0 tag checkout withscripts/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.spored-instance-role,spawn-instance-*). Thesetup-sweep-cross-account-role.shre-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.scripts/hardware-sensitive.txtlistslambda/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.