wsl2: stop spinning in for { <-ctx.Done() } after instance stop#4892
Open
mn-ram wants to merge 1 commit intolima-vm:masterfrom
Open
wsl2: stop spinning in for { <-ctx.Done() } after instance stop#4892mn-ram wants to merge 1 commit intolima-vm:masterfrom
mn-ram wants to merge 1 commit intolima-vm:masterfrom
Conversation
The boot-script goroutine in provisionVM wraps a single context-cancellation
wait in `for {}`. Once ctx is canceled (every limactl stop / shutdown),
<-ctx.Done() returns immediately on each iteration, and the goroutine
hot-loops calling getWslStatus and stopVM forever — pinning a CPU core and
flooding wslservice.exe with wsl.exe subprocess invocations.
The intent was clearly to wait once and stop the VM, so drop the for loop.
Signed-off-by: mn-ram <235066282+mn-ram@users.noreply.github.com>
Contributor
Author
|
The Logs:
This error is from Windows (Hyper-V), not the Go code touched here. That said, earlier loop spam ( Likely a flake — could you please re-run to confirm? |
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 #4891.
The boot-script goroutine in
provisionVMwraps a single context-cancellation wait infor {}. Oncectxis canceled (everylimactl stop/ shutdown),<-ctx.Done()returns immediately on every iteration, so the goroutine hot-loops callinggetWslStatusandstopVMforever — pinning a CPU core and floodingwslservice.exewithwsl.exesubprocesses.Drop the
for {/}wrapper so the goroutine waits once and exits.Test plan
GOOS=windows go build ./pkg/driver/wsl2/...GOOS=windows go vet ./pkg/driver/wsl2/...