Skip to content

Enable standalone mode on Windows#2178

Draft
odaneau-astro wants to merge 4 commits into
mainfrom
worktree-feat-standalone-windows-2177
Draft

Enable standalone mode on Windows#2178
odaneau-astro wants to merge 4 commits into
mainfrom
worktree-feat-standalone-windows-2177

Conversation

@odaneau-astro

@odaneau-astro odaneau-astro commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #2177

Standalone mode was disabled on Windows since PR #2034 because standalone.go used Unix-only syscalls inline (syscall.SysProcAttr{Setpgid}, syscall.Kill(-pid, SIGTERM/SIGKILL), signal.Notify(SIGINT, SIGTERM)). This change abstracts those into platform-specific files so the same standalone.go works on all platforms.

What changed

Concern Unix Windows
Process group Setpgid: true CREATE_NEW_PROCESS_GROUP
Graceful stop kill(-pid, SIGTERM) taskkill /T /PID
Force kill kill(-pid, SIGKILL) taskkill /F /T /PID
Signal handling SIGINT, SIGTERM os.Interrupt
Venv bin dir bin Scripts
PATH separator : ; (os.PathListSeparator)

Files

  • New: standalone_process_unix.go / standalone_process_windows.go — platform-specific helpers: setProcGroup, terminateProcessGroup, killProcessGroup, interruptSignals, venvBinDir
  • New: standalone_process_{unix,windows}_test.go — platform-specific test helpers (longSleepCommand, failCommand)
  • Modified: standalone.go — removed //go:build !windows, replaced all syscall.* calls with cross-platform helpers, use os.PathListSeparator for PATH/PYTHONPATH
  • Modified: standalone_test.go — kept //go:build !windows (existing tests validated on Unix only); replaced inline syscall usage with cross-platform helpers
  • Deleted: standalone_windows.go — the stub that returned errStandaloneWindows for every operation

Test strategy

The existing test suite stays behind //go:build !windows — these tests were written and validated on Unix and may have subtle platform assumptions beyond shell scripts (file permissions, path conventions, etc.). New Windows-specific tests should be added and validated on a real Windows CI runner as the feature matures.

Test plan

  • All 388 airflow package tests pass (macOS)
  • Cross-compiles cleanly: GOOS=windows GOARCH=amd64 go build ./...
  • Cross-compiles cleanly: GOOS=linux GOARCH=amd64 go build ./...
  • Manual test on Windows (needs CI or a Windows machine)
  • Add Windows-specific tests validated on Windows CI

🤖 Generated with Claude Code

Standalone mode was disabled on Windows (PR #2034) because the
implementation used Unix-only syscalls inline. This change abstracts
those into platform-specific files so the same standalone.go works
on all platforms.

Changes:
- Extract process group ops into standalone_process_{unix,windows}.go:
  setProcGroup, terminateProcessGroup, killProcessGroup, interruptSignals
- Extract venv bin dir into venvBinDir() (Unix: "bin", Windows: "Scripts")
- Use os.PathListSeparator for PATH/PYTHONPATH joining
- Remove the Windows stub (standalone_windows.go) that returned
  errStandaloneWindows for every operation
- Remove //go:build !windows from standalone.go and standalone_test.go

On Windows, process groups use CREATE_NEW_PROCESS_GROUP and tree
termination uses taskkill /T. Signal handling uses os.Interrupt
(Ctrl+C) since SIGTERM doesn't exist on Windows.

Closes #2177

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@odaneau-astro odaneau-astro requested a review from a team as a code owner June 17, 2026 12:21
@coveralls-official

coveralls-official Bot commented Jun 17, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 27689190148

Coverage increased (+0.01%) to 45.101%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: 8 uncovered changes across 2 files (20 of 28 lines covered, 71.43%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
airflow/standalone.go 13 8 61.54%
airflow/standalone_process_unix.go 15 12 80.0%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 56385
Covered Lines: 25430
Line Coverage: 45.1%
Coverage Strength: 8.0 hits per line

💛 - Coveralls

odaneau-astro and others added 2 commits June 17, 2026 08:29
…iles

Tests that use shell scripts (#!/bin/sh) as fake binaries, Unix PATH
separators, or process group management are moved to
standalone_unix_test.go with a //go:build !windows constraint.

The remaining tests in standalone_test.go run on all platforms.
Platform-specific test helpers (longSleepCommand, failCommand) are
in standalone_process_{unix,windows}_test.go.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Rather than splitting tests by heuristic, keep the entire existing
test suite behind //go:build !windows — these tests were written and
validated on Unix and may have subtle platform assumptions beyond
shell scripts. New Windows-specific tests can be added and validated
on a real Windows runner as the feature matures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@odaneau-astro odaneau-astro changed the title feat(standalone): enable standalone mode on Windows Enable standalone mode on Windows Jun 17, 2026
@odaneau-astro odaneau-astro marked this pull request as draft June 17, 2026 12:51
Three issues found during review of the Windows enablement PR:

1. Bash() and standaloneExecAirflowCommand() hardcoded "bash" which
   doesn't exist on Windows. Extract shellCommand() and
   interactiveShellArgs() into the platform-specific files so Unix
   uses bash and Windows uses cmd.exe.

2. terminateProcessGroup used taskkill without /F, which sends
   WM_CLOSE — ineffective for console processes like Python/Airflow.
   Replace with GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT), the
   proper Windows equivalent of SIGTERM. CREATE_NEW_PROCESS_GROUP
   (already set in setProcGroup) enables this.

3. NO_PROXY=* was injected unconditionally as a macOS _scproxy
   workaround but now ran on Windows too, where it could override
   registry-configured corporate proxy settings with no benefit.
   Guard with runtime.GOOS == darwin.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ashb

ashb commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

This might fix the astro command, but Airflow itself still won't run on Windows without modifictions will it?

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.

Enable standalone mode on Windows

2 participants