Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,23 @@ jobs:
- name: WSL info
if: matrix.provider == 'wsl'
shell: pwsh
env:
WSL_UTF8: '1'
run: |
wsl --update
wsl --version
wsl --status

- name: Uninstall WSL
if: matrix.provider == 'hyperv'
env:
WSL_UTF8: '1'
continue-on-error: true
shell: pwsh
run: |
wsl --uninstall
wsl --status

- name: Configure container policy
shell: pwsh
run: |
Expand Down
3 changes: 3 additions & 0 deletions pkg/machine/wsl/stubber.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ func (w WSLStubber) PrepareIgnition(_ *vmconfigs.MachineConfig, _ *ignition.Igni
}

func (w WSLStubber) Exists(name string) (bool, error) {
if !wutil.IsWSLInstalled() {
return false, nil
}
return isWSLExist(env.WithPodmanPrefix(name))
}

Expand Down
20 changes: 10 additions & 10 deletions pkg/machine/wsl/wutil/wutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package wutil

import (
"bufio"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -52,11 +53,7 @@ func SilentExecCmd(args ...string) *exec.Cmd {

func parseWSLStatus() wslStatus {
onceStatus.Do(func() {
status = wslStatus{
installed: false,
vmpFeatureEnabled: false,
wslFeatureEnabled: false,
}
status = wslStatus{}
cmd := SilentExecCmd("--status")
out, err := cmd.StdoutPipe()
cmd.Stderr = nil
Expand All @@ -66,14 +63,17 @@ func parseWSLStatus() wslStatus {
if err = cmd.Start(); err != nil {
return
}

status = matchOutputLine(out)

if err := cmd.Wait(); err != nil {
return
err = cmd.Wait()
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
// If `wsl --status` returns an exit error
// we assume that WSL isn't installed and
// override whatever was returned by
// matchOutputLine()
status = wslStatus{}
}
})

return status
}

Expand Down
Loading