Skip to content

fix(launch): single launches carry --spot-max-price and refuse --vpc without --subnet-id (#1388, #1389) - #1402

Merged
scttfrdmn merged 2 commits into
mainfrom
fix/1388-1389-single-launch-spot-vpc
Oct 28, 2026
Merged

scttfrdmn merged 2 commits into
mainfrom
fix/1388-1389-single-launch-spot-vpc

Conversation

@scttfrdmn

@scttfrdmn scttfrdmn commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1388
Fixes #1389

#1388: --spot-max-price on a single launch (Fixed)

buildLaunchConfig now sets SpotMaxPrice from --spot-max-price, after the truffle-input block, so the flag beats a piped price. Every non-sweep launch builds its config here: flags, pipe mode, and the job array and MPI cohorts, which copy that config. All of them now send SpotOptions.MaxPrice, and --dry-run shows (max $X/hr). The sweep-only copy in sweepBaseConfig (#1392) is removed because sweeps get the value from the same place. The sweep flag-table entry (viaConfig) is unchanged and still checked by TestSweepFlagRulesHoldAgainstTheCode. Detached members (#1353) take it from config.SpotMaxPrice through LaunchSettings. The batch queue already read it. task run takes neither flag.

#1389: --vpc needs --subnet-id or --az (Changed)

  • Deterministic subnet choice. GetSubnetForAZ now wraps the new Client.SubnetInAZ. It filters DescribeSubnets by vpc-id and availability-zone (it already filtered by both). Of the subnets returned, it picks the one with the most AvailableIpAddressCount, with ties going to the lowest subnet ID. Before, it took Subnets[0]. If the VPC has no subnet in that AZ, the error names both the AZ and the VPC. --fsx-create, multi-card EFA and the headless pkg/launcher FSx path all use this choice.
  • --vpc --az with no subnet. The pre-flight (ensureAMIAndPreflight step 0a, so every single launch, Linux or Windows, job array, MPI and --dry-run) calls resolveVPCSubnet. That resolves the subnet, prints using subnet <id> (<az>, <n> free IPs) in <vpc>, and sets config.SubnetID before anything is created. RunInstances, the FSx and the EFA interfaces then use that subnet.
  • --vpc with no --az and no subnet is refused at the top of runLaunch, before any AWS call. The message ends with "or pass --az to let spawn pick a subnet in that VPC". The batch queue resolves no subnet, so it refuses even with --az, and its message leaves out the --az hint. A backstop in buildLaunchConfig refuses a config that has a VPC and neither a subnet nor an AZ.
  • Sweeps are unchanged. fix(launch): parameter sweeps carry or refuse every launch flag (#1366) #1392's refusal still applies. Detached members are launched by the orchestrator Lambda from LaunchSettings, and a row can override az per member. Resolving there would mean a lookup for each (region, az) pair, threaded into each row's settings. That isn't cheap or consistent across the foreground and detached paths, so I left it alone.

Gates (each watched failing against a revert that compiles)

  • Most free IPs, then lowest ID: pkg/aws TestSubnetInAZPicksMostFreeThenLowestID runs every rotation of the subnet list, with decoys in another AZ and another VPC. The cmd test TestPreflightResolvesVPCAZToASubnet (linux and windows) uses the real client against a fake EC2.
    • Revert to the first-listed subnet: both fail (chose subnet-0ccc/subnet-0zzz, want subnet-0bbb), and so does the EFA test.
    • Revert the tie-break to the highest ID: all three fail.
  • --vpc --az resolves and launches there: TestPreflightResolvesVPCAZToASubnet fails when the resolveVPCSubnet call is removed from the pre-flight (SubnetID "", no calls). TestResolveVPCSubnet checks the exact printed line and that nothing is looked up when a subnet is given or there is no VPC.
    • pkg/aws TestLaunch_MultiEFAVPCAndAZUsesTheChosenSubnet runs Client.Launch with a VPC, an AZ and no subnet. Both interfaces must get the chosen subnet; it fails on the first-listed revert.
    • TestLaunch_SubnetIDReachesRunInstances covers a plain launch.
  • --vpc alone refused with zero calls: TestVPCWithoutSubnetIsRefusedBeforeAnyAWSCall has seven cases: linux, windows, dry-run, job array, mpi, batch queue, and batch queue with --az.
    • Disabling the flag check: all seven fail (1 AWS call(s): [GetCallerIdentity]).
    • Letting the batch queue accept --az: batch_queue_with_az fails.
  • --spot-max-price: TestSingleSpotLaunchCarriesSpotMaxPrice fails on revert (MaxPrice "" and "0.5000"), as does TestSweepFlagRulesHoldAgainstTheCode/spot-max-price.

Checks

From /private/tmp: make check, make lint (0 issues) and semgrep scan --config=auto --error . pass. api/public-surface.txt is regenerated with additions only (SubnetChoice, Client.SubnetInAZ). make cli-iam-actions reports no change. Help text is unchanged. No AWS calls were made.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.13559% with 7 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
pkg/aws/fsx.go 83.87% 5 Missing ⚠️
cmd/launch_config.go 95.83% 1 Missing ⚠️
cmd/launch_single.go 75.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

…without --subnet-id (#1388, #1389)

buildLaunchConfig now sets SpotMaxPrice from --spot-max-price (beating a
truffle-piped price), so single launches, job arrays and MPI cohorts send
MaxPrice; the sweep-only copy in sweepBaseConfig is removed.

--vpc without --subnet-id is refused at the top of runLaunch, before any
AWS call and every dispatch (single, Windows, dry-run, job array, MPI,
batch queue), with a backstop in buildLaunchConfig. It used to land in the
default VPC.

Fixes #1388
Fixes #1389
…pc alone still refused (#1389)

GetSubnetForAZ now wraps Client.SubnetInAZ: of the subnets in the VPC and
AZ, the most AvailableIpAddressCount, ties to the lowest ID (was
Subnets[0]). A --vpc --az launch with no subnet resolves it in the
pre-flight, prints 'using subnet <id> (<az>, <n> free IPs) in <vpc>', and
launches there, so multi-card EFA with --vpc --az keeps working. --vpc
without --az is refused before any AWS call, now offering --az; the batch
queue resolves no subnet and still needs --subnet-id. Sweeps unchanged.
CHANGELOG: #1389 moved under Changed.
@scttfrdmn
scttfrdmn force-pushed the fix/1388-1389-single-launch-spot-vpc branch from 81bcd25 to 5504065 Compare October 28, 2026 21:57
@scttfrdmn
scttfrdmn merged commit e07dfdb into main Oct 28, 2026
9 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1388-1389-single-launch-spot-vpc branch October 28, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant