-
Notifications
You must be signed in to change notification settings - Fork 693
CI: test and fix portfwd issue (w3m -dump
hangs)
#3708
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,11 +4,16 @@ | |
package portfwdserver | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"io" | ||
"net" | ||
"os" | ||
"strings" | ||
"time" | ||
|
||
"github.com/containers/gvisor-tap-vsock/pkg/tcpproxy" | ||
|
||
"github.com/lima-vm/lima/pkg/bicopy" | ||
"github.com/lima-vm/lima/pkg/guestagent/api" | ||
) | ||
|
@@ -35,7 +40,23 @@ func (s *TunnelServer) Start(stream api.GuestService_TunnelServer) error { | |
return err | ||
} | ||
rw := &GRPCServerRW{stream: stream, id: in.Id} | ||
bicopy.Bicopy(rw, conn, nil) | ||
|
||
// FIXME: consolidate bicopy and tcpproxy into one | ||
// | ||
// The bicopy package does not seem to work with `w3m -dump`: | ||
// https://github.com/lima-vm/lima/issues/3685 | ||
// | ||
// However, the tcpproxy package can't pass the CI for WSL2 (experimental): | ||
// https://github.com/lima-vm/lima/pull/3686#issuecomment-3034842616 | ||
if wsl2, _ := seemsWSL2(); wsl2 { | ||
bicopy.Bicopy(rw, conn, nil) | ||
} else { | ||
proxy := tcpproxy.DialProxy{DialContext: func(_ context.Context, _, _ string) (net.Conn, error) { | ||
return conn, nil | ||
}} | ||
proxy.HandleConn(rw) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This workaround is quite dirty, but let's merge this and call it a day to unblock the v1.2 release There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there an issue for cleaning this up in the future? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will open an issue after merging this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
return nil | ||
} | ||
|
||
|
@@ -83,3 +104,13 @@ func (g *GRPCServerRW) SetReadDeadline(_ time.Time) error { | |
func (g *GRPCServerRW) SetWriteDeadline(_ time.Time) error { | ||
return nil | ||
} | ||
|
||
// seemsWSL2 returns whether lima.env contains LIMA_CIDATA_VMTYPE=wsl2 . | ||
// This is a temporary workaround and has to be removed. | ||
func seemsWSL2() (bool, error) { | ||
b, err := os.ReadFile("/mnt/lima-cidata/lima.env") | ||
if err != nil { | ||
return false, err | ||
} | ||
return strings.Contains(string(b), "LIMA_CIDATA_VMTYPE=wsl2"), nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know if the server close the socket or only do shutdown(SHUT_RD)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.