Skip to content

Improve dapr init experience on Windows machines running WSL#1641

Open
WhitWaldo wants to merge 14 commits intodapr:masterfrom
WhitWaldo:windows-wsl-fallback
Open

Improve dapr init experience on Windows machines running WSL#1641
WhitWaldo wants to merge 14 commits intodapr:masterfrom
WhitWaldo:windows-wsl-fallback

Conversation

@WhitWaldo
Copy link
Copy Markdown

@WhitWaldo WhitWaldo commented May 2, 2026

Description

Implementing additional functionality for dapr init when running in elevated prompts on Windows to address port-busy errors for Dapr scheduler when WSL is installed on the system. If not elevated and the error is encountered on Windows, the output suggests launching as an elevated process and retrying (and why).

Otherwise, if the user is running the CLI in Windows, using an elevated command prompt and runs dapr init and has WSL2 installed, this will run as normal, but before it starts running the scheduler, it will:

  • Shut down the WSL instance
  • Stop the Windows NAT service

It will then proceed to run the Dapr Scheduler service as normal and this is expected to work this time. Then, it will restart WSL and start the Windows NAT service again, and complete as normal.

This was authored in Claude, but I gave it a manual pass to fix several things that just didn't look right and validated that tests appear comprehensive and pass locally.

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #1630

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

… elevated prompts on Windows to address port-busy errors for Dapr scheduler when WSL is installed on the system. If not elevated and the error is encountered on Windows, the output suggests launching as an elevated process and retrying (and why).

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo WhitWaldo self-assigned this May 2, 2026
@WhitWaldo WhitWaldo requested review from a team as code owners May 2, 2026 22:59
@WhitWaldo WhitWaldo added the kind/enhancement enhancement to an existing feature label May 2, 2026
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 2, 2026

Codecov Report

❌ Patch coverage is 29.78723% with 33 lines in your changes missing coverage. Please review.
✅ Project coverage is 15.75%. Comparing base (1c7e715) to head (84a8e70).
⚠️ Report is 13 commits behind head on master.

Files with missing lines Patch % Lines
pkg/standalone/standalone.go 19.51% 33 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1641      +/-   ##
==========================================
+ Coverage   15.15%   15.75%   +0.60%     
==========================================
  Files          64       65       +1     
  Lines        7191     7247      +56     
==========================================
+ Hits         1090     1142      +52     
- Misses       6016     6017       +1     
- Partials       85       88       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves the dapr init experience on Windows by detecting and remediating a common scheduler port-binding failure associated with WSL2/WinNAT, including tailored guidance when the CLI is not running elevated.

Changes:

  • Added Windows-specific helpers to detect elevation/WSL availability and to restart WSL/WinNAT as a remediation step.
  • Added a pre-flight port availability check for scheduler ports on non-elevated Windows when WSL is present, emitting guidance to rerun elevated.
  • Added unit tests for the new port-check helper logic and OS-specific stubs.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/standalone/standalone.go Adds scheduler port checks and Windows elevated remediation (WSL shutdown + WinNAT stop/start) around scheduler container startup.
pkg/standalone/wsl_windows.go Implements Windows elevation detection and WSL/WinNAT control helpers.
pkg/standalone/wsl_nowindows.go Adds non-Windows no-op stubs for the Windows-specific helpers.
pkg/standalone/wsl_windows_test.go Adds Windows-only tests ensuring the Windows helper functions are callable/non-blocking.
pkg/standalone/wsl_nowindows_test.go Adds non-Windows tests verifying the stubbed helper behavior.
pkg/standalone/wsl_test.go Adds cross-platform unit tests for port-check helper behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/standalone/standalone.go Outdated
Comment thread pkg/standalone/standalone.go Outdated
Comment thread pkg/standalone/standalone.go Outdated
Comment thread pkg/standalone/wsl_test.go Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/standalone/standalone.go
Comment thread pkg/standalone/standalone.go Outdated
Comment thread pkg/standalone/standalone.go
Comment thread pkg/standalone/wsl_test.go Outdated
WhitWaldo added 4 commits May 5, 2026 22:09
…er service

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
…ue in addition to other three outstanding constraints

Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/standalone/wsl_windows.go Outdated
Comment thread pkg/standalone/wsl_windows.go Outdated
Comment thread pkg/standalone/standalone.go
WhitWaldo added 3 commits May 5, 2026 22:24
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/standalone/wsl_test.go
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
@WhitWaldo WhitWaldo requested a review from Copilot May 6, 2026 04:17
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/standalone/standalone.go Outdated
Comment thread pkg/standalone/standalone.go
Comment thread pkg/standalone/standalone.go
Comment thread pkg/standalone/standalone.go
WhitWaldo and others added 3 commits May 5, 2026 23:22
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Whit Waldo <whit.waldo@innovian.net>
Signed-off-by: Whit Whit <whit.waldo@innovian.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement enhancement to an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: dapr init doesn't work

2 participants