Skip to content

Commit 34fa305

Browse files
committed
pkg/portfwdserver: Remove workaround for WSL2
Signed-off-by: Norio Nomura <norio.nomura@gmail.com>
1 parent 0c0a78d commit 34fa305

File tree

3 files changed

+8
-31
lines changed

3 files changed

+8
-31
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ jobs:
177177
- name: Integration tests (WSL2, Windows host)
178178
run: |
179179
$env:PATH = "$pwd\_output\bin;" + 'C:\msys64\usr\bin;' + $env:PATH
180-
pacman -Sy --noconfirm openbsd-netcat diffutils socat
180+
pacman -Sy --noconfirm openbsd-netcat diffutils socat w3m
181181
$env:MSYS2_ENV_CONV_EXCL = 'HOME_HOST;HOME_GUEST;_LIMA_WINDOWS_EXTRA_PATH'
182182
$env:HOME_HOST = $(cygpath.exe "$env:USERPROFILE")
183183
$env:HOME_GUEST = "/mnt$env:HOME_HOST"
@@ -206,7 +206,7 @@ jobs:
206206
- name: Integration tests (QEMU, Windows host)
207207
run: |
208208
$env:PATH = "$pwd\_output\bin;" + 'C:\msys64\usr\bin;' + 'C:\Program Files\QEMU;' + $env:PATH
209-
pacman -Sy --noconfirm openbsd-netcat diffutils socat
209+
pacman -Sy --noconfirm openbsd-netcat diffutils socat w3m
210210
$env:MSYS2_ENV_CONV_EXCL = 'HOME_HOST;HOME_GUEST;_LIMA_WINDOWS_EXTRA_PATH'
211211
$env:HOME_HOST = $(cygpath.exe "$env:USERPROFILE")
212212
$env:HOME_GUEST = "$env:HOME_HOST"

hack/test-templates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ if [[ -n ${CHECKS["port-forwards"]} ]]; then
489489
limactl shell "$NAME" $sudo $CONTAINER_ENGINE rm -f nginx
490490
fi
491491
fi
492-
if [[ ${NAME} != "alpine"* && ${NAME} != "wsl2"* ]] && command -v w3m >/dev/null; then
492+
if [[ ${NAME} != "alpine"* ]] && command -v w3m >/dev/null; then
493493
INFO "Testing https://github.com/lima-vm/lima/issues/3685 ([gRPC portfwd] client connection is not closed immediately when server closed the connection)"
494494
# Skip the test on Alpine, as systemd-run is missing
495495
# Skip the test on WSL2, as port forwarding is half broken https://github.com/lima-vm/lima/pull/3686#issuecomment-3034842616

pkg/portfwdserver/server.go

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@ import (
88
"errors"
99
"io"
1010
"net"
11-
"os"
12-
"strings"
1311
"time"
1412

1513
"github.com/containers/gvisor-tap-vsock/pkg/tcpproxy"
1614
"github.com/sirupsen/logrus"
1715

18-
"github.com/lima-vm/lima/v2/pkg/bicopy"
1916
"github.com/lima-vm/lima/v2/pkg/guestagent/api"
2017
)
2118

@@ -48,21 +45,11 @@ func (s *TunnelServer) Start(stream api.GuestService_TunnelServer) error {
4845
rw.Close()
4946
}()
5047

51-
// FIXME: consolidate bicopy and tcpproxy into one
52-
//
53-
// The bicopy package does not seem to work with `w3m -dump`:
54-
// https://github.com/lima-vm/lima/issues/3685
55-
//
56-
// However, the tcpproxy package can't pass the CI for WSL2 (experimental):
57-
// https://github.com/lima-vm/lima/pull/3686#issuecomment-3034842616
58-
if wsl2, _ := seemsWSL2(); wsl2 {
59-
go bicopy.Bicopy(rw, conn, nil)
60-
} else {
61-
proxy := tcpproxy.DialProxy{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
62-
return conn, nil
63-
}}
64-
go proxy.HandleConn(rw)
65-
}
48+
proxy := tcpproxy.DialProxy{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
49+
return conn, nil
50+
}}
51+
go proxy.HandleConn(rw)
52+
6653
// The stream will be closed when this function returns.
6754
// Wait here until rw.Close(), rw.CloseRead(), or rw.CloseWrite() is called.
6855
// We can't close rw.closeCh since the calling order of Close* methods is not guaranteed.
@@ -134,13 +121,3 @@ func (g *GRPCServerRW) SetReadDeadline(_ time.Time) error {
134121
func (g *GRPCServerRW) SetWriteDeadline(_ time.Time) error {
135122
return nil
136123
}
137-
138-
// seemsWSL2 returns whether lima.env contains LIMA_CIDATA_VMTYPE=wsl2 .
139-
// This is a temporary workaround and has to be removed.
140-
func seemsWSL2() (bool, error) {
141-
b, err := os.ReadFile("/mnt/lima-cidata/lima.env")
142-
if err != nil {
143-
return false, err
144-
}
145-
return strings.Contains(string(b), "LIMA_CIDATA_VMTYPE=wsl2"), nil
146-
}

0 commit comments

Comments
 (0)