Repository navigation
fix(launch): a nested-spawn role named directly requires --ttl (#1375) - #1381
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
--instance-profile spawn-instance-nested-* and a foreground sweep row naming one skipped --nested-spawn's --ttl rule. Every path that accepts a profile now applies it (or refuses the role outright: --iam-role, batch queue), and aws.Client.Launch and launcher.Provision enforce it for SDK callers. Fixes #1375
scttfrdmn
force-pushed
the
fix/1375-nested-profile-requires-ttl
branch
from
October 28, 2026 18:18
f691b34 to
d53e874
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.
A
spawn-instance-nested-*role may call RunInstances and iam:PassRole onspawn-instance-*.--nested-spawngives it only to an instance with a--ttl(#39), but naming the role directly skipped that rule. With this change, a profile or role that matchesaws.IsNestedSpawnRolegets the same treatment as--nested-spawnon every path that accepts one.Paths and treatment
spawn launch --instance-profile <nested>(single launch, plus--countjob arrays and--mpi, which share its config)--ttl. Refused inrunLaunchbefore any AWS call, ahead of the auditGetCallerIdentity. Same reason text as--nested-spawn requires --ttl. Can't be combined with--no-timeouteither, as with--nested-spawn. In wizard mode the TTL may come from the wizard, sorequireNestedSpawnTTLchecks the resolved config instead.spawn launch --iam-role <nested>(single, sweep, batch queue)CreateOrGetInstanceProfilealso refuses a nestedRoleName.--iam-rolegoes throughCreateOrGetInstanceProfile. For an existing nested role, that overwritesspored-baseline-policywith the default baseline, which breaks child launches because the nested variant exempts tag-on-create. With--iam-policy, it also overwrites the nested grant inspawn-scoped-policy. For a new name, it creates a role under the nested prefix with caller-chosen grants. The nested role's grants are fixed so they can be audited.spawn launch --batch-queue/--queue-template --instance-profile <nested>--nested-spawnis already refused with a batch queue: a queue runner isn't a head node.--no-detach, or--detachwith no--max-concurrent), via a row'siam_role:,defaults: iam_role:, or--instance-profileiam_role:, else--instance-profile(folded into defaults byapplyCLIIAMToSweep), elsedefaults: iam_role:. The TTL is the row'sttl:, elsedefaults: ttl:, which already holds--ttl(applyCLISpendControlsToSweep). That'ssweepRowBound, the resolution the--no-detachguard uses. An idle timeout doesn't count.spawn schedulespawn resume(foreground)--instance-profile/--ttl, so the row needs attl:in the file.spawn burst --instance-profilevalidateBurstParams, checked first).--ttl, so in practice this never fires. It's there so the rule lives in one function and the discovery gate covers burst.spawn task run,pool,app launch,image,pipeline launch, service, MPI/task cohortsaws.Client.Launchbackstop.spawn-instance-<hash>, the pool worker role, orspored-instance-profile), and none of those can match the nested prefix.aws.Client.LaunchIamInstanceProfilewith noTTLbefore any AWS call.launcher.Provision(lagotto, MCP)ValidateDurations, before the AMI lookup.Provision(ValidateDurationsonly parses a TTL that is set). So without this check an SDK caller could provision a nested profile with no TTL, andClient.Launchwould only catch it after the AMI and IAM work.New in
pkg/aws:CheckNestedSpawnTTL,LaunchConfig.ValidateNestedSpawnTTL,NestedSpawnTTLError(the--nested-spawnrefusal, now shared),NestedSpawnRoleReservedError,ErrNestedSpawnNeedsTTL,ErrNestedSpawnRoleReserved.api/public-surface.txtis regenerated. Help text:--instance-profilenow says a nested-spawn role needs--ttl.docs-gen/launch.mdis regenerated.No new IAM permission for any principal. No AWS calls were made.
Gates (each watched failing against a revert that compiles)
The revert in each case was
false && err != nilon the check, which compiles and vets clean.TestNestedInstanceProfileWithoutTTLRefusedBeforeAnyAWSCall(runLaunch through a counting endpoint). With therunLaunchcall reverted: "the refused launch made 1 AWS call(s) first".TestNestedInstanceProfileWithTTLProceeds. With the revert makingCheckNestedSpawnTTLignore the TTL: "launch --instance-profile ... --ttl 8h was refused".TestForegroundSweepRowWithNestedProfileAndNoTTLRefused(--no-detach, row 1 nested, idle timeout only, 0 AWS calls). With the sweep call reverted, it fails at the AMI lookup:detect AMI ... GetParameter 400.TestProvisionRefusesNestedProfileWithoutTTLBeforeAnyAWSCall. With the revert, it fails at the AMI lookup (SSM GetParameter 403).TestEveryProfileFlagRoutesThroughTheNestedSpawnCheck(discovery). It walksrootCmdfor every command with--instance-profileor--iam-role, runs itsRunEwith the nested role and an empty--ttlthrough a counting endpoint, and requires a nested refusal and 0 AWS calls. It fails if it discovers nothing, or if it misses launch or burst. Reverts: the runLaunch check made the launch subtests fail (1 AWS call,--name is required). The burst check made the burst subtest fail (--ttl is required: burst instances must have a TTL, the wrong refusal). The--iam-rolerefusal made the launch--iam-rolesubtest fail.Also gated, each failing against its revert:
TestLaunchRefusesNestedProfileWithoutTTLBeforeAnyAWSCall(theClient.Launchbackstop; the revert reached STS),TestCreateOrGetInstanceProfileRefusesANestedRoleName(the revert reached IAM GetRole),TestResumeRefusesANestedRowWithoutTTL,TestNestedSpawnRoleFlagValidation. Units:TestNestedSweepRowResolution(precedence),TestCheckNestedSpawnTTL(shared wording), andTestDetachedSweepWithNestedRowGetsTheDetachedRefusal, which checks that an auto-detached sweep still gets #1372's refusal rather than an invitation to add a--ttlit would refuse anyway.Fixes #1375