Repository navigation
fix(sweep): boot spored on detached sweep members and verify it (#1323, #1313) - #1332
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
#1313) Detached (Lambda-orchestrated) sweep members launched with no UserData, so spored never ran on them: no in-instance TTL, idle, cost or completion enforcement, only the TTL reaper. - The CLI renders each member's user data with buildUserData, the builder the foreground sweep path uses, and ships it in the params under spawn_user_data (defaults when every member agrees, per row otherwise), for both spawn launch --param-file and spawn schedule create. The Lambda passes it to RunInstances verbatim and refuses a member without one. - The CLI ensures spored-instance-profile for members with no iam_role; the Lambda's fallback is that profile. The cross-account role may pass spored-instance-role (and spawnd-role) to EC2 only. - The orchestrator terminates a member still running with no spawn:last-heartbeat past the CLI's spored budget (5m Linux, 10m Windows) and counts it failed, in both polling loops; the multi-region loop now decides completion with completionStatus. Fixes #1323 Fixes #1313
scttfrdmn
force-pushed
the
fix/1323-1313-detached-sweep-spored
branch
from
October 26, 2026 22:44
58f65c7 to
5a3cb8e
Compare
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.
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.
P0 cost safety. Detached (Lambda-orchestrated) sweep members, which are the default for
--param-file, launched with no UserData, so spored never ran on them. They had no in-instance TTL, idle, cost or completion enforcement, and only the TTL reaper ended them, in the regions it covers. This PR boots spored on every member and then verifies it (#1313).Fixes #1323
Fixes #1313
Where the bootstrap is built: the CLI, shipped in the params
The CLI renders each member's user data with
buildUserData, the same builder the foreground sweep loop uses. It calls it on the member'sbuildLaunchConfigFromParamsconfig, thenencodeUserDataForOS, and puts the result in the uploaded params underspawn_user_data. When every member's bytes are identical (the usual case) they go underdefaults:once; otherwise each row gets its own copy. The Lambda passes the value to RunInstances verbatim.Why the CLI and not the Lambda:
--plugin/--configplugins and--user-datacontents.launcher.CallerVersionis stamped only into the CLI.deploy-sweep-orchestrator.shbuilds with a plaingo buildagainst areplaced spawn, soPublishedBodyVersion()would return "" there and every member would get the inline body. Rendering in the CLI gives the same result as the foreground path, release stub or dev inline included. Dependency weight was not the deciding factor:go list -depsgives 793 packages for the orchestrator and 801 withpkg/launcheradded.spawn schedule createseeds the bootstrap the same way. scheduler-handler re-encodes onlydefaults/params, so the key survives there without a redeploy. The schedule's ownsweep_name/max_concurrent/launch_delayare left out of the member configs.spawn_user_data(reservedRowKeys), and any value it does carry is dropped before seeding.Instance profile and PassRole
spored-instance-profile(SetupSporedIAMRole) for members with noiam_role, as the foreground path does. This runs after the confirmation prompt, so declining the prompt creates nothing. The Lambda's fallback is now that profile instead of the hand-madespawnd-role.scripts/setup-sweep-cross-account-role.shnow grants this statement toSpawnSweepCrossAccountRole:{"Effect":"Allow","Action":["iam:PassRole"], "Resource":["arn:aws:iam::${CURRENT_ACCOUNT_ID}:role/spored-instance-role", "arn:aws:iam::${CURRENT_ACCOUNT_ID}:role/spawnd-role"], "Condition":{"StringEquals":{"iam:PassedToService":"ec2.amazonaws.com"}}}iam:PassRoleonrole/spored-instance-rolewithiam:PassedToService=ec2.amazonaws.com. Deny: the same role withPassedToService=lambda.amazonaws.com, anyrole/spawn-instance-*, androle/SpawnSweepCrossAccountRole. Per the PutRolePolicy lesson, do one realput-role-policyon a throwaway role first.ec2:DescribeInstancesandec2:TerminateInstanceson*, so Detached (Lambda-orchestrated) sweeps never verify spored on their members (#1305 follow-up) #1313 needs no new EC2 grant.#1313: verifying spored
countActiveInstances(single-region) andcountActiveByRegion(multi-region) already describe every active member on each poll. A member that is stillrunningwith nospawn:last-heartbeatpast the CLI's budget is terminated. The budget is 5 minutes on Linux and 10 on Windows (sporedVerifyTimeout, #1305), measured from the recordedLaunchedAt. The terminated member is recorded as a failed row (moved from launched to failed, sweep-wide and per region), so it frees its slot. A member whose terminate call fails stays active and is retried on the next poll. The multi-region loop now decides completion withcompletionStatustoo, so a sweep in which no member came up records FAILED.Gates, each watched failing against a compiling revert
TestDetachedMemberUserDataIsTheForegroundMembers(cmd): a member's seeded user data equals, byte for byte and decoded,encodeUserDataForOS(buildUserData(...))for the same member config; member-specific input (completion_file) reaches itTestMemberLaunchesWithTheCLIsBootstrap(lambda): RunInstancesUserDatais the CLI's value verbatim (row overrides defaults);IamInstanceProfileset; fallback isspored-instance-profileUserDatadropped; profile dropped; fallbackspawnd-roleTestEveryRunInstancesCallUsesTheBuilder: everyRunInstancescall is fed bybuildRunInstancesInput, and there is exactly one input literalTestDetachedBootstrapIsTheReleaseStubOrDevInline:CallerVersion=0.147.0gives the stubSPAWN_BS_VERSION='0.147.0';devgives the inline bodyCallerVersioncleared in the seederTestMemberWithoutBootstrapIsNotLaunchedif falseTestSingleRegion/MultiRegionReapsMembersWithoutSpored: only the no-heartbeat member past budget is terminated; the verified, young and Windows-within-10m members are kept; Failed/Launched and per-region tallies move; active count dropsTestFailedTerminationIsRetriedNotRecorded,TestSporedBudgetsMatchTheCLI,TestBothLoopsDecideCompletionTheSameWayCOMPLETEDunconditionalTestSweepCrossAccountRoleMayPassSporedsRole(scripts): PassRole namesSporedRoleNameread from pkg/aws, has no wildcard,PassedToService=ec2role/*; PassedToService changedTestEnsureDetachedInstanceProfile,TestSeedScheduleParams_CarriesTheBootstrap,TestLaunchSweepDetachedSeedsBeforeUpload,TestDetachedBootstrapWrittenOnceAndNeverFromTheFile,TestDetachedBootstrapKeylessWithoutALocalKeyTestDetachedSweepSeedsEveryKeyTheLambdaReadsnow scans all orchestrator sources and resolves a named-constant keyDeploy (not done here: no AWS)
us-east-1:AWS_PROFILE=spore-host-infra ./scripts/deploy-sweep-orchestrator.sh. The script buildsGOOS=linux GOARCH=amd64, runsupdate-function-code, re-asserts timeout 900 and memory 512, tagsspawn:version, sets log retention, and verifiesCodeSha256.SPAWN_MEMBER_ACCOUNT=<id> ./scripts/setup-sweep-cross-account-role.sh. It is an idempotent put-role-policy that adds the PassRole statement above. Do this before or with step 1: without it, every member's RunInstances is refused once the Lambda passesspored-instance-profile.Follow-ups filed
spawn:*config tags, so a row'scommand:never runs and idle/cost/on-complete are not enforced. spored now enforcesspawn:ttl-deadlineonly.--iam-role/--iam-policy/--instance-profileget a profile the orchestrator may not pass, so every member is refused. This is not new.Checks
make check: all steps pass except step 7,check-build-tags. That step fails on the/private/tmpworktree path and lists only e2e/integration files this PR does not touch. It fails the same way on main.make lint(inside check): 0 issues in all 10 modules.semgrep scan --config=auto --error .: clean.