Skip to content

client: use go-winio.DialPipe directly#50125

Merged
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:client_winio_dialpipe
Jun 30, 2025
Merged

client: use go-winio.DialPipe directly#50125
cpuguy83 merged 1 commit intomoby:masterfrom
thaJeztah:client_winio_dialpipe

Conversation

@thaJeztah
Copy link
Member

The go-connections package implementation is only a shallow wrapper around go-winio for named pipes; use the go-winio implementation directly.

- How to verify it

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added status/2-code-review kind/refactor PR's that refactor, or clean-up code labels Jun 2, 2025

// dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows.
func dialPipeContext(ctx context.Context, string) (net.Conn, error) {
return nil, syscall.EAFNOSUPPORT
Copy link
Member Author

Choose a reason for hiding this comment

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

We could probably change this to ErrProtocolNotAvailable (or any other error?) 🤔

The go-connections package implementation is only a shallow wrapper
around go-winio for named pipes; use the go-winio implementation
directly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah force-pushed the client_winio_dialpipe branch from 3bdd26c to accbfde Compare June 2, 2025 12:38
return sockets.DialPipe(cli.addr, 32*time.Second)
ctx, cancel := context.WithTimeout(ctx, 32*time.Second)
defer cancel()
return dialPipeContext(ctx, cli.addr)
Copy link
Member Author

Choose a reason for hiding this comment

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

🫠 looks like testutil has its own separate implementation of all of this

func npipeDial(path string, timeout time.Duration) (net.Conn, error) {
return winio.DialPipe(path, &timeout)
}

// SockConn opens a connection on the specified socket
func SockConn(timeout time.Duration, daemon string) (net.Conn, error) {
daemonURL, err := url.Parse(daemon)
if err != nil {
return nil, errors.Wrapf(err, "could not parse url %q", daemon)
}
var c net.Conn
switch daemonURL.Scheme {
case "npipe":
return npipeDial(daemonURL.Path, timeout)
case "unix":
return net.DialTimeout(daemonURL.Scheme, daemonURL.Path, timeout)
case "tcp":
if os.Getenv("DOCKER_TLS_VERIFY") != "" {
// Setup the socket TLS configuration.
tlsConfig, err := getTLSConfig()
if err != nil {
return nil, err
}
dialer := &net.Dialer{Timeout: timeout}
return tls.DialWithDialer(dialer, daemonURL.Scheme, daemonURL.Host, tlsConfig)
}
return net.DialTimeout(daemonURL.Scheme, daemonURL.Host, timeout)
default:
return c, errors.Errorf("unknown scheme %v (%s)", daemonURL.Scheme, daemon)
}
}

@thaJeztah thaJeztah marked this pull request as ready for review June 6, 2025 11:36
@thaJeztah thaJeztah requested a review from Copilot June 27, 2025 10:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the shallow go-connections wrapper for Windows named pipes with direct calls to go-winio’s DialPipeContext, and provides a stub on non-Windows platforms.

  • Introduces dialPipeContext in client_windows.go to forward to winio.DialPipeContext with context support
  • Adds a stub dialPipeContext in client_unix.go that returns EAFNOSUPPORT
  • Updates the main dialer to use the new dialPipeContext (with timeout) instead of sockets.DialPipe

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
client/client_windows.go Added dialPipeContext forwarding to winio.DialPipeContext
client/client_unix.go Added unsupported stub for non-Windows dialPipeContext
client/client.go Switched npipe case to use new dialPipeContext with timeout
Comments suppressed due to low confidence (2)

client/client_unix.go:15

  • Update this comment to accurately describe the stub behavior on non-Windows, e.g., that dialPipeContext always returns syscall.EAFNOSUPPORT on Unix.
// dialPipeContext connects to a Windows named pipe. It is not supported on non-Windows.

client/client_windows.go:15

  • [nitpick] Add unit tests for dialPipeContext to verify successful connections and context timeout handling on Windows.
func dialPipeContext(ctx context.Context, addr string) (net.Conn, error) {

@thaJeztah thaJeztah requested review from dmcgowan and vvoland June 27, 2025 17:15
@thaJeztah
Copy link
Member Author

cc @vvoland @dmcgowan

@cpuguy83 cpuguy83 merged commit 89eb408 into moby:master Jun 30, 2025
228 of 229 checks passed
@thaJeztah thaJeztah deleted the client_winio_dialpipe branch June 30, 2025 20:17
@thaJeztah thaJeztah added this to the 29.0.0 milestone Oct 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants