Skip to content

Refuse launch flags a Windows instance cannot honour (#1022) - #1042

Merged
scttfrdmn merged 1 commit into
mainfrom
fix/1022
Oct 16, 2026
Merged

scttfrdmn merged 1 commit into
mainfrom
fix/1022

Conversation

@scttfrdmn

Copy link
Copy Markdown
Contributor

Fixes #1022

What

--command, --user-data and --user-data-file were accepted for a Windows launch and then dropped. buildWindowsUserData takes only the SSH key, and nothing on Windows reads the spawn:command tag. The workload never ran, --on-complete never fired, and the instance billed until its TTL.

I chose refuse over implement. I can't run PowerShell here (no pwsh), so a PowerShell --command runner could only be string-tested. The issue also asks that a Windows workload start be gated on spored is-spot-replacement, which exists only in #1021, and has no Windows counterpart even there. Implementing it can come later, as a feature. Silently dropping the flag was the bug.

  • cmd/launch_windows_flags.go: windowsLaunchFlags records a decision for every spawn launch flag, local and inherited: honoured on Windows, or refused with a reason. windowsUnsupportedFlags refuses a Windows launch that sets any refused flag, and names them all in one error.
  • Where it runs:
    • At the top of runLaunch, for an explicit --os windows, before any AWS call. This is the only check the batch-queue and detached-sweep dispatches get, because they never resolve an OS.
    • Inside windowsLifecycleGuard, where an auto-detected Windows AMI is first known. That covers a single launch, job arrays, foreground sweeps and --dry-run.
  • Backstop: buildUserData refuses a Windows command or custom user data at the point where they would be dropped.

Refused on Windows, each dropped on the Windows path today:

  • --command, --user-data and --user-data-file.
  • --plugin and --config: plugins.json is written only by the Linux bootstrap.
  • --session-timeout: a profile.d script.
  • --params and --param-file: per-row commands and PARAM_* values travel in tags that only the Linux bootstrap reads.
  • --batch-queue and --queue-template: bash runner.
  • --strata-*: al2023 environments.
  • --mpi and its options.
  • --efs-*, --attach-volume and --fsx-*. The storage script is skipped for Windows, so an attached volume is never mounted, and --fsx-create created and billed a Lustre filesystem that nothing could mount.

Honoured: EC2 parameters, IAM, CLI-side behaviour, and the lifecycle tags spored enforces as a Windows service: TTL, idle, on-complete, completion file, pre-stop via PowerShell, webhooks, DNS and cost limit. Each entry carries its reason.

Tests (cmd/launch_windows_flags_test.go)

  • TestEveryLaunchFlagHasAWindowsRule discovers the flags from the cobra command, Flags() and InheritedFlags(). It fails on a flag with no entry, on an entry with no reason, on a stale entry, and on a discovery of fewer than 50 flags.
  • TestWindowsFlagRulesAreEnforced marks each discovered flag set, one at a time, on a copy of the flag set, so no globals are mutated. Refused flags must be refused and named, honoured ones accepted, and Linux is never refused.
  • TestWindowsRefusesCommandAndUserData names the issue's flags plus the confirmed drops (plugin, fsx-create, efs-id, attach-volume, mpi, params, batch-queue) outright. The table-driven test reads the same table as the guard, so on its own it cannot catch one of them being reclassified as honoured.
  • TestWindowsDryRunRefusesCommand goes through runLaunchDryRun on Substrate and asserts the refusal and that no plan is printed. Linux is unaffected.
  • TestRunLaunchRefusesWindowsSweepBeforeDispatch checks that runLaunch with --os windows --params is refused before the sweep dispatch.
  • TestBuildUserDataRefusesWindowsWorkload covers the backstop.
  • TestWindowsGuardIgnoresDefaults checks that defaulted flags, such as --session-timeout (default 30m) and --efs-mount-point, don't refuse a plain Windows launch.

I watched each test fail against a revert that compiles (go vet clean):

Revert Failing tests
guard made a no-op 4
call dropped from windowsLifecycleGuard dry-run test
runLaunch call made false && err != nil sweep-dispatch test
backstop made if false backstop test
a table entry deleted discovery test

Checks

  • make check (credentials stripped): the only failure is the known Docker-only TestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker.
  • make check-nested: 9 modules clean.
  • golangci-lint --new-from-rev=origin/main ./cmd/...: 0 issues.

Caveats

  • Behaviour change: a Windows launch that passed any refused flag, and so silently ran without it, now fails. That is the intent, but it is visible.
  • Batch queue and detached sweeps are checked only against an explicit --os windows. With an auto-detected Windows AMI they still don't resolve an OS. That is a pre-existing gap, not widened here.
  • --attach-volume: Windows may see the raw disk, but the flag's contract (a mount point) can't be met, so it is refused.
  • Not run live: nothing here was tested against a real Windows instance.

@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cmd/launch_config.go 75.00% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

--command, --user-data and --user-data-file were accepted for a Windows
launch and dropped: buildWindowsUserData takes only the SSH key, and nothing
on Windows reads the spawn:command tag. The workload never ran, --on-complete
never fired, and the instance billed until its TTL.

Every launch flag now has a recorded Windows disposition in
windowsLaunchFlags: honoured, or refused with a reason. The guard runs at the
top of runLaunch for an explicit --os windows (covering the batch-queue and
detached-sweep dispatches, which never resolve an OS) and inside
windowsLifecycleGuard, where an auto-detected Windows AMI is first known
(single, array, foreground sweep and --dry-run). buildUserData refuses a
Windows command or custom user data as a backstop.

Refused besides the issue's three: --plugin/--config, --session-timeout,
--params/--param-file, --batch-queue/--queue-template, --strata-*, --mpi and
its options, --efs-*, --attach-volume and --fsx-* (each was dropped on the
Windows path; --fsx-create created a billed filesystem nothing mounted).
@scttfrdmn
scttfrdmn merged commit 243bc5c into main Oct 16, 2026
8 checks passed
@scttfrdmn
scttfrdmn deleted the fix/1022 branch October 16, 2026 20:44
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.

Windows launches silently drop --command and --user-data

1 participant