Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(wsl): Non-English system users cannot use wsl machine #22932

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

BlackHole1
Copy link
Contributor

@BlackHole1 BlackHole1 commented Jun 7, 2024

When checking if WSL is already installed, podman relies on the English string returned by WSL.
However, in non-English systems, WSL will return content in the current system language (such as Chinese).
To avoid this situation, we cannot simply rely on the content returned by WSL and need to manually check if the kernel exists.

51-07 17 51@2x

The English translation of the Chinese in the above image is:

Default version: 2

The Windows Subsystem for Linux kernel can be manually updated using "wsl --update," but due to your system settings, automatic updates are not possible.
To receive automatic kernel updates, enable the Windows Update setting: "Receive updates for other Microsoft products when you update Windows."
For more information, visit https://aka.ms/wsl2kernel.

WSL 2 kernel file not found. To update or restore the kernel, run "wsl --update."

Does this PR introduce a user-facing change?

Fix bug where non-English systems failed to check for WSL properly.

[NO NEW TESTS NEEDED]

@baude baude added the No New Tests Allow PR to proceed without adding regression tests label Jun 7, 2024
@baude
Copy link
Member

baude commented Jun 7, 2024

in general, i agree

/approve

Copy link
Contributor

openshift-ci bot commented Jun 7, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude, BlackHole1

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 7, 2024
@baude
Copy link
Member

baude commented Jun 7, 2024

updated release note as well.

}

if user := os.Getenv("USERPROFILE"); user != "" {
return filepath.Join(user, "AppData", "Local"), true
Copy link
Member

Choose a reason for hiding this comment

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

is this defined anywhere as a constant; or is it something we use more than once around our code?

Copy link
Contributor Author

@BlackHole1 BlackHole1 Jun 11, 2024

Choose a reason for hiding this comment

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

is this defined anywhere as a constant;

Not defined elsewhere

is it something we use more than once around our code?

Currently, it is only being used here.

return `C:\Windows\System32`
}

func getProgramFiles() string {
Copy link
Member

Choose a reason for hiding this comment

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

seems like some of these might be more usefully placed in general windows utils thing. nit only, no worries

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean it's better to put: getLocalAppData getSystem32Root getProgramFiles in https://github.com/containers/podman/blob/main/pkg/machine/wsl/util_windows.go?

The reason I didn't put them in util_windows.go is because they belong to two different packages, and these three functions are only used here.
If you think it's necessary, I will move them to util_windows.go.

if strings.Contains(line, match) {
return true
}
func existsKernel() bool {
Copy link
Member

Choose a reason for hiding this comment

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

would you mind a little more concise naming of this function? like WSL something or another.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you have any recommendations? Or move the code to the IsWSLInstalled function?

@baude
Copy link
Member

baude commented Jun 7, 2024

@BlackHole1 tyvm for the contribution. couple of nitty comments but else generally LGTM

@BlackHole1
Copy link
Contributor Author

@baude Thank you for your review. I am on vacation and will update this PR in 3-4 days :)

@BlackHole1
Copy link
Contributor Author

@baude Friendly ping :)

@baude
Copy link
Member

baude commented Jun 14, 2024

@baude Friendly ping :)

well Im on PTO too! :) most of my comments were optional. need someone else from the team to review as well.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 19, 2024
When checking if WSL is already installed, podman relies on the English string returned by WSL.
However, in non-English systems, WSL will return content in the current system language (such as Chinese).
To avoid this situation, we cannot simply rely on the content returned by WSL and need to manually check if the kernel exists.

Signed-off-by: Kevin Cui <bh@bugs.cc>
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 20, 2024
@rhatdan
Copy link
Member

rhatdan commented Jun 24, 2024

@n1hility PTAL

@ashley-cui
Copy link
Member

Tried to test on an non-English VM but I don't meet the min system requirements..

Anyway, tested on my Windows box locally and it seems to work. LGTM other than @baude's concerns.

@BlackHole1
Copy link
Contributor Author

So far, there has been no further discussion. Should we perhaps continue to wait for the code review from @n1hility 👀 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. machine No New Tests Allow PR to proceed without adding regression tests release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants