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: guestagent port forwarding behavior on wsl2 #2213

Merged
merged 1 commit into from
Feb 17, 2024

Conversation

pendo324
Copy link
Contributor

@pendo324 pendo324 commented Feb 16, 2024

The recent change to make the guestagent use grpc broke some special-cased behavior for port forwarding on WSL2.

Turns out the special-casing is unnecessary though, so I just removed it.

Example

We'll host a server, and show that the Lima logs are correct, and that it's accessible from the host system.

Host a server on port 8080
nerdctl.lima run --rm -p 8080:80 nginx:latest
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/02/16 22:56:32 [notice] 1#1: using the "epoll" event method
2024/02/16 22:56:32 [notice] 1#1: nginx/1.25.4
2024/02/16 22:56:32 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2024/02/16 22:56:32 [notice] 1#1: OS: Linux 5.15.146.1-microsoft-standard-WSL2
2024/02/16 22:56:32 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1073741816:1073741816
2024/02/16 22:56:32 [notice] 1#1: start worker processes
2024/02/16 22:56:32 [notice] 1#1: start worker process 29
2024/02/16 22:56:32 [notice] 1#1: start worker process 30
2024/02/16 22:56:32 [notice] 1#1: start worker process 31
2024/02/16 22:56:32 [notice] 1#1: start worker process 32
2024/02/16 22:56:32 [notice] 1#1: start worker process 33
2024/02/16 22:56:32 [notice] 1#1: start worker process 34
2024/02/16 22:56:32 [notice] 1#1: start worker process 35
2024/02/16 22:56:32 [notice] 1#1: start worker process 36
2024/02/16 22:56:32 [notice] 1#1: start worker process 37
2024/02/16 22:56:32 [notice] 1#1: start worker process 38
2024/02/16 22:56:32 [notice] 1#1: start worker process 39
2024/02/16 22:56:32 [notice] 1#1: start worker process 40
2024/02/16 22:56:32 [notice] 1#1: start worker process 41
2024/02/16 22:56:32 [notice] 1#1: start worker process 42
2024/02/16 22:56:32 [notice] 1#1: start worker process 43
2024/02/16 22:56:32 [notice] 1#1: start worker process 44
2024/02/16 22:56:32 [notice] 1#1: start worker process 45
2024/02/16 22:56:32 [notice] 1#1: start worker process 46
2024/02/16 22:56:32 [notice] 1#1: start worker process 47
2024/02/16 22:56:32 [notice] 1#1: start worker process 48
2024/02/16 22:56:32 [notice] 1#1: start worker process 49
2024/02/16 22:56:32 [notice] 1#1: start worker process 50
2024/02/16 22:56:32 [notice] 1#1: start worker process 51
2024/02/16 22:56:32 [notice] 1#1: start worker process 52
2024/02/16 22:56:32 [notice] 1#1: start worker process 53
2024/02/16 22:56:32 [notice] 1#1: start worker process 54
2024/02/16 22:56:32 [notice] 1#1: start worker process 55
2024/02/16 22:56:32 [notice] 1#1: start worker process 56
2024/02/16 22:56:32 [notice] 1#1: start worker process 57
2024/02/16 22:56:32 [notice] 1#1: start worker process 58
2024/02/16 22:56:32 [notice] 1#1: start worker process 59
2024/02/16 22:56:32 [notice] 1#1: start worker process 60
2024/02/16 22:56:32 [notice] 1#1: start worker process 61
2024/02/16 22:56:32 [notice] 1#1: start worker process 62
2024/02/16 22:56:32 [notice] 1#1: start worker process 63
2024/02/16 22:56:32 [notice] 1#1: start worker process 64
2024/02/16 22:56:32 [notice] 1#1: start worker process 65
2024/02/16 22:56:32 [notice] 1#1: start worker process 66
2024/02/16 22:56:32 [notice] 1#1: start worker process 67
2024/02/16 22:56:32 [notice] 1#1: start worker process 68
2024/02/16 22:56:32 [notice] 1#1: start worker process 69
2024/02/16 22:56:32 [notice] 1#1: start worker process 70
2024/02/16 22:56:32 [notice] 1#1: start worker process 71
2024/02/16 22:56:32 [notice] 1#1: start worker process 72
2024/02/16 22:56:32 [notice] 1#1: start worker process 73
2024/02/16 22:56:32 [notice] 1#1: start worker process 74
2024/02/16 22:56:32 [notice] 1#1: start worker process 75
2024/02/16 22:56:32 [notice] 1#1: start worker process 76
10.4.0.1 - - [16/Feb/2024:22:56:48 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/8.0.1" "-"
10.4.0.1 - - [16/Feb/2024:22:56:58 +0000] "GET / HTTP/1.1" 200 615 "-" "curl/8.4.0" "-"
Lima logs (ha.stderr.log, truncated)
...
{"level":"debug","msg":"guest agent event: {Time:2024-02-16 17:33:01.337334017 -0500 EST LocalPortsAdded:[{IP:0.0.0.0 Port:8080}] LocalPortsRemoved:[] Errors:[]}","time":"2024-02-16T17:33:01-05:00"}
{"level":"info","msg":"Forwarding TCP from 0.0.0.0:8080 to 127.0.0.1:8080","time":"2024-02-16T17:33:01-05:00"}
{"level":"debug","msg":"guest agent event: {Time:2024-02-16 17:33:58.338057783 -0500 EST LocalPortsAdded:[] LocalPortsRemoved:[{IP:0.0.0.0 Port:8080}] Errors:[]}","time":"2024-02-16T17:33:58-05:00"}
{"level":"info","msg":"Stopping forwarding TCP from 0.0.0.0:8080 to 127.0.0.1:8080","time":"2024-02-16T17:33:58-05:00"}
...
Access from the host
PS> curl http://localhost:8080
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

@pendo324
Copy link
Contributor Author

Fixes #2209 (specifically the issue I mentioned here #2209 (comment))

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

I have not verified that the special case is not needed on WSL2, but otherwise the removal looks correct to me.

@jandubois jandubois added this to the v0.21.0 milestone Feb 16, 2024
@jandubois jandubois merged commit eb7b7e6 into lima-vm:master Feb 17, 2024
24 checks passed
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