Skip to content

Enable port forwarding tests for WSL2 #3357

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

Merged
merged 1 commit into from
Mar 19, 2025

Conversation

arixmkii
Copy link
Contributor

@arixmkii arixmkii commented Mar 17, 2025

Specifics:

  • 127.0.0.1 always forwarded for 127.0.0.1 and 0.0.0.0 binds
  • slirp IP address is not available.

All related cases are skipped based on instance name.

It probably should be machine type, but I would need to collect more knowledge as to how add this test to Perl script.

This one is full of pretty crazy stuff. It took me 20 CI runs in my forked repo in addition to local runs to figure this out. So, some explanation would be helpful.

my $instanceType = qx(limactl ls --json "$instance" | jq -r '.vmType' | sed s/x/x/);

sed s/x/x is no-op on Unix trick to remove \r from output on Windows, because chomp fails to do so.

The only reasonable provider of nc was msys2 package manager. But it was impossible to use from Git shell - application will blow up, because of conflicting msys2 runtimes. The only way to use it is through some proxy of a native Windows process, which would separate the msys2 runtimes - something like cmd /C "bash -c 'nc ... which is awfully complicated. Alternative is to write a bridge app like this one - https://github.com/arixmkii/go-wsllinks I used it in my CI setup to separate msys2 apps from different roots, but there are no prebuilt versions as of now.

So, the solution is to use msys2 shell, where we can add packages and install all the needed dependencies, but this is known to not work for Lima, because of some sort of bug in ssh, which is addressed in Git distro. For this purpose we will provide Git distro as additional dependency path for limactl via $env:_LIMA_WINDOWS_EXTRA_PATH = 'C:\Program Files\Git\usr\bin' from the recently merged #3347

@arixmkii
Copy link
Contributor Author

It will also need nc (I had it in my setup, where I tested). I will work on this more.

@arixmkii arixmkii marked this pull request as draft March 17, 2025 20:40
@arixmkii arixmkii force-pushed the wsl2-port-forwarding branch from 80c494e to 72588bf Compare March 18, 2025 20:41
@arixmkii arixmkii marked this pull request as ready for review March 18, 2025 20:49
@arixmkii
Copy link
Contributor Author

Vuln check is wrong here. This PR only touches CI related files. No production code changes introduced.

@AkihiroSuda
Copy link
Member

Vuln check is wrong here. This PR only touches CI related files. No production code changes introduced.

Could you try rebase?

Signed-off-by: Arthur Sengileyev <[email protected]>
@arixmkii arixmkii force-pushed the wsl2-port-forwarding branch from 72588bf to 52dddb6 Compare March 19, 2025 08:13
@arixmkii
Copy link
Contributor Author

Rebased. I added some minor tweaks with the rebase. I removed update for system path via registry, because normally builds don't modify system /etc/environment or .bashrc settings w/o need. And this was working in my fork w/o registry tweaks. And I renamed $env:Path to $env:PATH. It is case insensitive in Powershell, but this way it is more consistent with other env vars within same block of code.

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 786c1f5 into lima-vm:master Mar 19, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants