Repository navigation
fix(sweep): carry every RunInstances setting to detached sweep members, refuse the rest (#1353) - #1367
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…s, refuse the rest (#1353) Detached members were launched with only the instance type, AMI, key, profile, user data and tags. The CLI now resolves each member's RunInstances-side settings (aws.LaunchSettings, versioned, strictly decoded) and the orchestrator applies them with the composition Client.Launch uses. Settings the orchestrator cannot honour are refused at --detach. Discovery gates hold every LaunchConfig field to carried or refused.
scttfrdmn
force-pushed
the
fix/1353-detached-member-settings
branch
from
October 27, 2026 05:54
3e0ae31 to
e41f94c
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 #1353
A detached (Lambda-orchestrated) sweep member was launched with only the instance type, AMI, key, profile, user data and tags. Every other RunInstances setting a foreground member honours was dropped on the way.
How it works now
Client.Launchthat turns aLaunchConfiginto RunInstances fields is nowapplyLaunchSettings(pkg/aws/launch_settings.go). It covers block devices, CPU options, network interfaces, placement, hibernation, Spot, capacity reservation and IMDS.Client.Launchcalls it, and so does the orchestrator, throughaws.LaunchSettings.Apply. Multi-card EFA stays inLaunch, because it needs AWS calls and an Elastic IP.seedDetachedBootstrapresolves each member'saws.LaunchSettingswithClient.ResolveLaunchSettings. That makes the same lookupsLaunchmakes: the AMI root device and its snapshot minimum, and the type's memory for a hibernating root. The result ships per row asspawn_launch_settings. The key is reserved, so a param file cannot set it.LaunchSettingscarriesschema(LaunchSettingsSchema = 1).DecodeLaunchSettingsrefuses a missing schema, any other schema, and any unknown field, nested ones included (DisallowUnknownFields). For params that carryspawn_launch_settings, the orchestrator refuses a member whose settings it cannot fully apply. It names the member, and the refusal is not a capacity error. A hibernating Spot member, which would need a persistent request, is refused inApplyas well as by the CLI's existing guard.--detach.detachedSettingsGuardruns before anything is uploaded. Each error names the setting and a remedy.SpotOptions.MaxPrice.Compatibility with older CLIs and existing schedules
spawn-sweep-orchestratoris shared, hosted infra, so after redeploy it serves older CLIs too.spawn_launch_settingskey (legacy params): the member launches exactly as the pre-Detached sweep members drop every non-tag RunInstances setting: volume_size, security groups, subnet/AZ, spot_max_price, hibernation, EFA, placement (#1330 follow-up) #1353 orchestrator composed it. It gets the barespotparam asMarketType: spotand none of the settings. One log line per sweep (per execution environment) says the settings were not carried and names the CLI version from the member'sspawn:versiontag, or "not recorded". The member is not refused.spawn schedule create(the schedule record'sS3ParamsKey). On every firing,downloadParamsyaml-decodes them andprepareSweepre-stages them unchanged withsweep.EncodeParams. So a schedule an older CLI created stays legacy for its whole life and takes the legacy path. It gets the new settings only when re-created.spawn_user_dataor nospawn_tagsare refused by the unreleased fix(sweep): boot spored on detached sweep members and verify it (#1323, #1313) #1332/fix(sweep): give detached members their tags, passable profiles and row user_data (#1330, #1331, #1327) #1354 checks. That covers every v0.146.0-or-older CLI and every schedule such a CLI created, because the v0.146.0 orchestrator had nospored.goand wrote its own tags. Filed as Redeployed sweep orchestrator refuses every sweep and schedule from a v0.146.0-or-older CLI (#1323/#1330 checks) #1368 for an owner decision before the orchestrator is redeployed. This PR's legacy path therefore applies to params that have the bootstrap and tags but no settings.Deploy order: deploy the orchestrator before, or together with, the CLI release. An orchestrator older than this one ignores
spawn_launch_settings, so a new CLI in front of it loses the settings silently. This orchestrator handles both old and new params (subject to #1368). Note that the deployed v0.146.0 orchestrator also ignoresspawn_user_dataandspawn_tags.Settings table: what a foreground member honours vs a detached member
Foreground member =
buildLaunchConfigFromParams(base CLI config, defaults, row)+defaultSweepMember→Client.Launch. "Before" is origin/main; "after" is this PR.volume_size/--volume-size(RootVolumeSizeGiB) + AMI-snapshot minimum + AMI root device name (#25/#284)root_volume_gib,root_device_name)--security-group(SecurityGroupIDs)--subnet(SubnetID)az/--az(AvailabilityZone)spot(Spot)MarketType: spotSpotOptions)spot_max_price(SpotMaxPrice)hibernate,hibernate_on_idle,--on-idle hibernate,on_complete: hibernate(Hibernate,HibernateOnIdle):HibernationOptions+ RAM-sized encrypted root--efasingle interface (EFAEnabled)--efa-interfaces> 1 (EFAInterfaces; needs EIP association/release)--placement-group(PlacementGroup)--reservation-id(ReservationID)--capacity-block(CapacityBlock)--nested-virtualization(NestedVirtualization)--attach-volume(AttachVolumes: block devices from snapshots)EBSEncrypted,IMDSv2Enforced,IMDSv2HopLimit(compliance; not set on sweep paths today)EBSKMSKeyIDcustomer-managed key (not set on sweep paths today)--vpcwithout--subnet(VPCID)--fsx-create(+ lifecycle/ttl/capacity/bucket)--fsx-recalla|b,c5.*)InstanceType,AMI,KeyName,IamInstanceProfile,UserDataCustomUserData,JobArrayCommand,CompletionFile,TargetOS(user-data side)spawn_user_data, #1323/#1327)--tag, ...)spawn_tags, #1330)ClientToken,PlacementGroupPrefix,DNSFunctionARN,FSxPending*FSxPendingis set only by the refused--fsx-create)Note 1:
Client.Launchalso copies each snapshot's custom tags onto its volume after launch, best effort (#161). The orchestrator does not do that copy. The volumes still get the member's tags throughTagSpecifications.The full per-field classification, with a reason for every field not carried, is
detachedDispositionsincmd/launch_sweep_detached_settings_test.go.Gates (each watched failing against a compiling revert)
pkg/awsTestDetachedMemberRunInstancesIsTheForegroundMembers: everyLaunchConfigfield is discovered by reflection and set alone over 5 bases (plain, spot, imdsv2, reservation, encrypted). Wherever a field changesClient.Launch's composition, the detached path (settings → JSON → strict decode →Apply) must produce an identical request. It must also refuse rather than fall back when the foreground would make a persistent Spot request. Reverts: droppingSubnetIDfromLaunchSettings.config()failed on all bases, and droppingSpotMaxPricefromNewLaunchSettingsfailed on the spot base.cmdTestDetachedMemberSettingsAreTheForegroundMembers: whatseedDetachedBootstrapships per row, decoded as the orchestrator decodes it, equals the settings of the config the foreground loop builds for that member. Covered: CLI flags (subnet, SG, placement, EFA, nested virt, reservation, attach volume) and row keys (volume_size,az,spot,spot_max_price,hibernate). Revert: not writing the key fails with "member 0 carries no spawn_launch_settings".TestMemberLaunchesWithTheCLIsSettings:buildRunInstancesInputapplies the shipped settings. Revert: skippingApplyfails on Placement, NetworkInterfaces, InstanceMarketOptions, BlockDeviceMappings and CpuOptions.--detach.TestDetachedSweepRefusesWhatTheOrchestratorCannotLaunch:seedDetachedBootstrap, which runs before upload in bothlaunchSweepDetachedandspawn schedule, errors for each of the 6 cases, names the setting and its remedy, and ships no settings. Revert: disabling the--fsx-createcase failed here and in the discovery gate.TestDetachedSweepCarriesOrRefusesEveryLaunchSetting(cmd): everyLaunchConfigfield needs a disposition, and each claim is checked mechanically. "settings" must changeaws.LaunchSettings, "tags" must changeBuildLaunchTags, "refused" must be refused, and a field carried some other way, or not at all, must change none of them. Revert: addingEnclaveEnabled booltoLaunchConfigfailed with "has no detached-sweep disposition".applyLaunchSettings(EnclaveOptions) but not carried inLaunchSettingsfailed the pkg/aws gate on every base.TestLegacyParamsMemberLaunchesAsBefore: no settings key, spot true and false. A bareMarketType: spotwith noSpotOptions, and no block devices, NICs, placement, hibernation, CPU or IMDS options. Reverts: restoring the refusal failed it, and dropping the bare-spot handling failed it.TestScheduleReplayedLegacyParamsMemberLaunches: stored params go through yaml decode as scheduler-handler'sdownloadParamsdoes, thensweep.EncodeParamsasprepareSweepdoes, then the orchestrator's JSON decode andmergeParams, thenbuildRunInstancesInput. Same two reverts, and both failed it.TestDecodeLaunchSettingsRefusesWhatItCannotApply(unknown field, unknown nested field, newer schema, no schema) and LambdaTestMemberWithoutApplicableSettingsIsNotLaunched. Revert: removingDisallowUnknownFields(and the schema check) failed both, and the Lambda one launched on the unknown field. After the legacy rework this was re-run, along with the "other schema" and "not an object" cases. The pkg/aws equivalence and cmd discovery gates are unchanged.The existing
TestDetachedSweepSeedsEveryKeyTheLambdaReadsnow matchesgetRawParamtoo, and holdsspawn_launch_settingson both sides.spotstays on its key list, read on the legacy path.IAM
None needed. The member-account role (
scripts/setup-sweep-cross-account-role.sh) already grantsec2:RunInstancesonResource: "*", which covers the subnet, security-group, network-interface, placement-group, capacity-reservation and snapshot resources. The orchestrator makes no new API calls. Encryption uses only the AWS-managedaws/ebskey, because a customer-managed key is refused. The CLI-side lookups (DescribeImages,DescribeInstanceTypes) are ones the foreground path already makes.make cli-iam-actionsreports no change, and the iamcoverage gate passes.Live deploys needed (not done here)
scripts/deploy-sweep-orchestrator.sh) before or with this release (see Deploy order). Decide Redeployed sweep orchestrator refuses every sweep and schedule from a v0.146.0-or-older CLI (#1323/#1330 checks) #1368 first.Checks
make checkpassed.make lint: 0 issues in all 10 modules.semgrep scan --config=auto --error .is clean (two test decodes moved frominterface{}tomap[string]interface{}).make api-snapshotwas regenerated: additions only (LaunchSettings,LaunchSettingsVolume,LaunchSettingsSchema,NewLaunchSettings,DecodeLaunchSettings,(*Client).ResolveLaunchSettings).make cli-iam-actions: no change.Not verified on AWS: no live sweep was run.
Follow-ups filed: #1368 (the redeployed orchestrator refuses v0.146.0-CLI sweeps and schedules through the #1323/#1330 checks), #1366 (foreground sweeps silently drop
--fsx-create,--fsx-recalland--vpcwithout--subnet).