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

WSL: Implement docker plugin integration in go #5924

Merged

Conversation

mook-as
Copy link
Contributor

@mook-as mook-as commented Nov 3, 2023

This avoids assumptions about what is available inside the target distros (we no longer require /bin/sh and ln).

This was spawned from #5832.

Copy link
Contributor

@ericpromislow ericpromislow left a comment

Choose a reason for hiding this comment

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

Unit tests fail on WIndows.

First, every time I run it I get this message:

For this generation to compile you need to have some packages in your go.mod:

        * github.com/go-openapi/runtime
        * github.com/jessevdk/go-flags

I still see this even after running go mod tidy in src/go/wsl-helper. Maybe it needs to be run somewhere else?

Then the tests fail with a large number of lines of errors, starting like so:

--- FAIL: TestContainersCreate (0.06s)
    --- FAIL: TestContainersCreate/bind (0.03s)
        containers_create_windows_test.go:57:
                Error Trace:    C:/Users/eric/rancher-desktop/src/go/wsl-helper/pkg/dockerproxy/mungers/containers_create_windows_test.go:57
                Error:          Received unexpected error:
                                could not translate bind path C:\Users\eric\AppData\Local\Temp\TestContainersCreatebind3996221649\001: error getting WSL path: exec: "wsl": executable file not found in %PATH%
                Test:           TestContainersCreate/bind
    --- FAIL: TestContainersCreate/mount (0.03s)
        containers_create_windows_test.go:92:
                Error Trace:    C:/Users/eric/rancher-desktop/src/go/wsl-helper/pkg/dockerproxy/mungers/containers_create_windows_test.go:92
                Error:          Received unexpected error:
                                could not translate mount path C:\Users\eric\AppData\Local\Temp\TestContainersCreatemount2728444168\001: error getting WSL path: exec: "wsl": executable file not found in %PATH%
                Test:           TestContainersCreate/mount
FAIL
FAIL    github.com/rancher-sandbox/rancher-desktop/src/go/wsl-helper/pkg/dockerproxy/mungers    0.333s
ok      github.com/rancher-sandbox/rancher-desktop/src/go/wsl-helper/pkg/dockerproxy/platform   (cached)
ok      github.com/rancher-sandbox/rancher-desktop/src/go/wsl-helper/pkg/dockerproxy/util       (cached)
--- FAIL: TestRemoveHostFileEntry (0.00s)
    hostfile_test.go:82:
                Error Trace:    C:/Users/eric/rancher-desktop/src/go/wsl-helper/pkg/host/hostfile_test.go:82
                Error:          Received unexpected error:
                                rename C:\Users\eric\AppData\Local\Temp\tmpRDHostsFile1155500918 C:\Users\eric\AppData\Local\Temp\TestRemoveHostFileEntry3891314604\001\hosts: Access is denied.
                Test:           TestRemoveHostFileEntry

This avoids assumptions about what is available inside the target distros
(we no longer require /bin/sh and ln).

Signed-off-by: Mark Yen <[email protected]>
On Windows, we must close the file before renaming on top of it.  While
this code isn't really used on Windows (it's only for Linux distros in
WSL), there doesn't seem to be much harm in fixing it.

Signed-off-by: Mark Yen <[email protected]>
@mook-as mook-as force-pushed the wsl/docker-plugin-integration-go branch from 7cf8e69 to 7e85f32 Compare November 14, 2023 22:41
@mook-as
Copy link
Contributor Author

mook-as commented Nov 14, 2023

Fixed the second test failure (from hostfile, which wasn't part of this PR). The other failure about failing to find wsl will need to be fixed on your system… you're expected to have WSL correctly installed before development.

@ericpromislow
Copy link
Contributor

wsl.exe is definitely in the path. It's at c:\Windows\system32\wsl.exe --- nothing would work if that directory wasn't in $PATH

Copy link
Contributor

@ericpromislow ericpromislow left a comment

Choose a reason for hiding this comment

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

Works, tests pass when the r-d distro has been installed, and code is readable, so approved

@mook-as mook-as merged commit 223d80b into rancher-sandbox:main Nov 16, 2023
10 checks passed
@mook-as mook-as deleted the wsl/docker-plugin-integration-go branch November 16, 2023 21:27
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.

2 participants