Repository navigation
fix(sweep): resume re-creates a deleted spawn-instance-* profile from the recorded IAM config (#1385) - #1395
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
… the recorded IAM config (#1385) A sweep checkpoint stored neither the profile the CLI IAM flags resolved to nor how it was made. Resume reloads the param file, which never held it, so a resumed member silently got spored-instance-profile; and a spawn-instance-* profile named in the file was reused without being re-created, failing at RunInstances once the idle-role sweep deleted it. New checkpoints (and a local record for detached sweeps) carry the profile and its IAMRoleConfig. Before the first launch, resume checks each spawn-created profile (iam:GetInstanceProfile): an existing one is reused unchanged, a gone one is re-created through the same CreateOrGetInstanceProfile call and must return the same name. A gone profile with no record, a changed --iam-policy-file, or an old checkpoint whose own instances show a different profile refuses the resume with nothing launched. Fixes #1385
scttfrdmn
force-pushed
the
fix/1385-resume-recreates-role
branch
from
October 28, 2026 20:19
cdfd461 to
eb1f3dd
Compare
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 #1385
What checkpoints stored
Nothing about IAM.
SweepStateheld the param-file path and instance records only.applyCLIIAMToSweepwrites the CLI profile into the in-memoryDefaults["iam_role"], and resume re-parses the file from disk, so:--iam-policy/--s3-read/... resumed its pending members with spored-instance-profile (a silent role change, worse than the issue described);spawn-instance-*profile named by the param file was reused without being re-created, and fails at RunInstances once the idle-role sweep (Leave no trace: reap per-task spawn-instance-<hash> IAM roles and instance profiles once no instance uses them #1300/fix(reaper): keep spawn-instance-* roles an enabled schedule still names (#1378) #1386) deletes it.Change
SweepStategainsiam_recordedandiam_role(SweepIAMRole: profile, verbatim flag, the fullIAMRoleConfigwith stable JSON names, the policy file's sha256, and the original flags for messages). Written on both checkpoint writes inrunSweepLaunch. A detached sweep writes the same record to~/.spawn/sweeps/detached-iam/<id>.jsonbefore the params upload (the orchestrator PutItems its whole DynamoDB record, so a new attribute there would be dropped).spawn resume,spawn sweep resume):applyRecordedIAMrestores the CLI profile into defaults;relaunchPendingcallsensureResumeProfilesbefore the first launch. Each spawn-created profile (spawn-instance-* or recorded-with-config) gets oneInstanceProfileReady(iam:GetInstanceProfile). If it exists, it is reused unchanged with no IAM writes. If it is gone, it is re-created viaCreateOrGetInstanceProfile(original config)(orSetupNestedSpawnProfilefor a nested role), and the returned name must match. All checks run before any write.--iam-policy-filethat is missing or changed; an old checkpoint whose own still-visible instances carry a profile different from what the resume would use.ensureDetachedResumeProfilere-creates from the local record beforeInvokeSweepOrchestrator. With no record (older sweep, other machine), it prints a note that it can't check.aws.Client.InstanceProfileReady(added;api/public-surface.txtregenerated).cli-iam-actionsis unchanged becauseiam:GetInstanceProfileis already listed forsweep resume. No new permission for any principal.Gates (each watched failing against a compiling revert)
TestResume_RecreatesDeletedSpawnRoleWithOriginalPolicyBeforeLaunch: the call log isready, create, launch, launch, and the create uses the original config. Fails with the ensure call removed fromrelaunchPendingand withapplyRecordedIAMmade a no-op.TestSweepCheckpointRecordsCLIIAMConfig: fails whenrunSweepLaunchrecordsIAMRole: nil.TestResume_OldCheckpointWithRoleGoneIsRefusedWithZeroLaunches: zero launches, no create, only the readiness read. Fails without the ensure call, and when the unrecorded gone-role branch returns nil.TestResume_OldCheckpointRefusesADifferentRole: fails with the drift check disabled.TestResume_ExistingRoleReusedUnchanged: log isready, launch, launch. Fails when the readiness short-circuit is removed (always re-create).TestDetachedResume_RecreatesRecordedRole: fails when the record isn't loaded.TestResumePathsReachTheIAMRecord: AST ordering in runResume, relaunchPending, resumeSweepDetached and launchSweepDetached.TestResume_ChangedPolicyFileIsRefusedandTestResume_RecreatesNestedSpawnRole.make check,make lint(0 issues),semgrep scan --config=auto --error .all pass. No help text changed. Not exercised against AWS.Follow-up filed: #1394 (resume also drops CLI
--ttl/--idle-timeout/--cost-limitand skips the 1h idle default).