Skip to content

fix(sweep-orchestrator): stop a legacy sweep at a missing spored-instance-profile and name the remedy (#1369) - #1387

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1369-legacy-member-profile
Oct 28, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1369-legacy-member-profile

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1369

What

A member from a v0.146.0-or-older CLI's params (or a schedule one created) that names no iam_role launches with spored-instance-profile, the fallback in buildRunInstancesInput (#1368). That CLI never ensured the profile on the detached path, so an account that only ever ran detached sweeps or schedules may not have it. In that case EC2 refuses every such member.

The orchestrator now classifies the refusal. A member matches when:

For such a member:

  • Not capacity. isCapacityError returns false for it, so none of the member's other instance types are tried.

  • Fail fast. On both the single-region path (launchBatch, pulled out of runPollingLoop) and the multi-region path (launchAcrossRegions, which drains every region's queue), the members not yet attempted are skipped. The sweep then finishes FAILED, even if some members with their own iam_role launched before it (abortedStatus). Members that are already running stay monitored until they finish, so Detached (Lambda-orchestrated) sweeps never verify spored on their members (#1305 follow-up) #1313's heartbeat check still covers them.

  • The remedy is named. It appears in the member's row error and in the sweep's error_message, which spawn status --sweep-id prints as Error::

    • CLI sweep: re-run with spawn v0.147.0 or later, spawn launch --param-file <params-file>.
    • Scheduled sweep: spawn schedule cancel <schedule-id>, then spawn schedule create <params-file> with its --cron/--at.

    Both commands already call ensureDetachedInstanceProfile (launchSweepDetached and seedScheduleParams, covered by TestLaunchSweepDetachedSeedsBeforeUpload and TestSeedScheduleParams_CarriesTheBootstrap). It creates spored-instance-profile with the user's credentials before anything is uploaded. spawn schedule create launches nothing itself. No remedy command was changed. spawn resume --detach is not named because it ensures no profile and the orchestrator does not resume a FAILED sweep. spawn onboard is not named because it is the portal BYOA flow and does not touch this profile. spawn doctor is not named because it is read-only by contract.

Non-legacy members keep the existing behaviour. A CLI-rendered member that gets the same error fails its row with EC2's error and no remedy, is not retried as capacity, and the sweep's other members are still attempted. That CLI ensured the profile moments before it uploaded, so the cause there is propagation or a deletion since then, and "re-run with a current spawn" is what the user just did.

No IAM changes to the orchestrator, the cross-account role, or any member-account role. There is no spawnd-role fallback: that role has no ec2:CreateTags, so #1313 would kill the member.

Gates (each watched failing against a compiling mutation)

Gate Mutation Result
TestLegacyMemberMissingProfileStopsTheSweep (CLI + scheduled remedies, single-region), ...MultiRegionSweep, TestLegacyProfileClassificationIsNarrow classifyLaunchError returns err unchanged all 3 FAIL
Not retried as capacity (same two sweep tests assert exactly one RunInstances, for t3.micro of t3.micro|t3.small) isCapacityError returns true for the profile error both FAIL
Remaining members not attempted, single-region launchBatch ignores the abort FAIL
Remaining members not attempted, multi-region (queue in a second region also drained) abort flag never set FAIL
TestCLIRenderedMemberMissingProfileKeepsGoing (non-legacy keeps behaviour) classification ignores isLegacyParams FAIL
TestStoppedSweepIsFailedWhateverLaunched abortedStatus returns completionStatus's value FAIL

On a full revert of the non-test code the tests don't compile. The capacity gate is a regression guard: on unmodified main the profile error was already non-capacity, so the gate fails only against the mutation.

Checks

make check, make lint (0 issues, all 10 modules), and semgrep scan --config=auto --error . are clean. go test -race passes in lambda/sweep-orchestrator. Help text is unchanged, so gen-docs was not needed. No AWS calls were made, so this is not live-verified.

Deploy

This takes effect only once the hand-deployed spawn-sweep-orchestrator is redeployed. After the release that carries it, run scripts/deploy-sweep-orchestrator.sh from a clean checkout of that release tag; the script refuses anything else. Snapshot the function configuration before deploying and diff it afterwards.

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…ance-profile and name the remedy (#1369)

A legacy member (v0.146.0-or-older CLI params, or a schedule one created)
with no iam_role launches with spored-instance-profile, which that CLI never
ensured on the detached path. EC2 refuses it with InvalidParameterValue
"Invalid IAM Instance Profile name". The orchestrator now classifies that
refusal for legacy members: not capacity (no other instance type tried), the
remaining members are not attempted on either launch path, and the sweep
finishes FAILED with an error naming the remedy (re-run with spawn v0.147.0+,
or re-create the schedule), both of which ensure the profile with the user's
credentials. CLI-rendered members keep the existing behaviour. No IAM change.
@scttfrdmn
scttfrdmn force-pushed the fix/1369-legacy-member-profile branch from 1cc2b2a to aeedc2a Compare October 28, 2026 19:07
@scttfrdmn
scttfrdmn merged commit 021fb56 into main Oct 28, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1369-legacy-member-profile branch October 28, 2026 19:26
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.

Legacy detached members with no iam_role need spored-instance-profile, which a v0.146.0-only account may not have

1 participant