Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mook-as committed Oct 11, 2024
1 parent 6cf793b commit 8227d04
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions .github/workflows/windows-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
run: yarn test:e2e
env:
RD_DEBUG_ENABLED: '1'
DEBUG: '*,-babel'
- name: Upload failure reports
uses: actions/upload-artifact@v4
if: always()
Expand Down
2 changes: 1 addition & 1 deletion src/go/wsl-helper/pkg/dockerproxy/platform/vsock_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ type vsockListener struct {
func (v *vsockListener) Accept() (net.Conn, error) {
fd, sa, err := unix.Accept4(v.fd, unix.SOCK_NONBLOCK)
if err != nil {
return nil, err
return nil, fmt.Errorf("error accept()ing connection: %w", err)
}
return newVsockConn(uintptr(fd), &v.local, sockaddrToVsock(sa)), nil
}
Expand Down
24 changes: 21 additions & 3 deletions src/go/wsl-helper/pkg/dockerproxy/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
package dockerproxy

import (
"errors"
"fmt"
"net"
"os"
Expand All @@ -28,6 +29,7 @@ import (
"time"

"github.com/linuxkit/virtsock/pkg/vsock"
"github.com/sirupsen/logrus"
"golang.org/x/sys/unix"

"github.com/rancher-sandbox/rancher-desktop/src/go/wsl-helper/pkg/dockerproxy/platform"
Expand Down Expand Up @@ -127,11 +129,23 @@ func Start(port uint32, dockerSocket string, args []string) error {
return err
}

for {
err := listenOnVsock(port, dockerSocket)
if err != nil {
logrus.Fatalf("docker-proxy: error listening on vsock: %s", err)
break
}
}
return nil
}

func listenOnVsock(port uint32, dockerSocket string) error {
listener, err := platform.ListenVsockNonBlocking(vsock.CIDAny, port)
if err != nil {
return fmt.Errorf("could not listen on vsock port %08x: %w", port, err)
}
defer listener.Close()
logrus.Infof("docker-proxy: listening on vsock port %08x", port)

sigch := make(chan os.Signal, 1)
signal.Notify(sigch, unix.SIGTERM)
Expand All @@ -143,7 +157,11 @@ func Start(port uint32, dockerSocket string, args []string) error {
for {
conn, err := listener.Accept()
if err != nil {
fmt.Printf("error accepting client connection: %s\n", err)
logrus.Errorf("docker-proxy: error accepting client connection: %s", err)
if errors.Is(err, unix.EINVAL) {
// This does not recover; return and re-listen
return nil
}
continue
}
go handleConnection(conn, dockerSocket)
Expand All @@ -155,13 +173,13 @@ func Start(port uint32, dockerSocket string, args []string) error {
func handleConnection(conn net.Conn, dockerPath string) {
dockerConn, err := net.Dial("unix", dockerPath)
if err != nil {
fmt.Printf("could not connect to docker: %s\n", err)
logrus.Errorf("could not connect to docker: %s", err)
return
}
defer dockerConn.Close()
err = util.Pipe(conn, dockerConn)
if err != nil {
fmt.Printf("error forwarding docker connection: %s\n", err)
logrus.Errorf("error forwarding docker connection: %s", err)
return
}
}

0 comments on commit 8227d04

Please sign in to comment.