Skip to content

Commit e8887c4

Browse files
committed
pkg/portfwdserver: Remove workaround for WSL2
Signed-off-by: Norio Nomura <[email protected]>
1 parent 0c0a78d commit e8887c4

File tree

2 files changed

+6
-29
lines changed

2 files changed

+6
-29
lines changed

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)