mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-17 02:06:23 +00:00
cri-client: normalize unix socket endpoints in target helper
This commit is contained in:
@@ -19,6 +19,12 @@ package cri
|
||||
import "strings"
|
||||
|
||||
func clientTargetForAddress(addr string) string {
|
||||
// Defensive: normalize callers that pass a unix endpoint instead of the
|
||||
// parsed socket path.
|
||||
if strings.HasPrefix(addr, "unix:///") {
|
||||
addr = strings.TrimPrefix(addr, "unix://")
|
||||
}
|
||||
|
||||
// grpc defaults to the DNS resolver for bare targets. Use the passthrough
|
||||
// resolver for socket-style addresses so the custom dialer gets the raw path.
|
||||
if strings.HasPrefix(addr, "/") {
|
||||
|
||||
@@ -29,6 +29,11 @@ func TestClientTargetForAddress(t *testing.T) {
|
||||
addr: "/run/containerd/containerd.sock",
|
||||
want: "passthrough:////run/containerd/containerd.sock",
|
||||
},
|
||||
{
|
||||
name: "unix socket endpoint",
|
||||
addr: "unix:///run/containerd/containerd.sock",
|
||||
want: "passthrough:////run/containerd/containerd.sock",
|
||||
},
|
||||
{
|
||||
name: "windows pipe path",
|
||||
addr: "//./pipe/containerd-containerd",
|
||||
|
||||
Reference in New Issue
Block a user