From fb674f8b48aa96a2b76823579fd4ba3fd41ba207 Mon Sep 17 00:00:00 2001 From: Maksym Pavlenko Date: Tue, 21 May 2024 15:41:34 -0700 Subject: [PATCH] Add resolver workaround for error: name resolver error: produced zero addresses Signed-off-by: Maksym Pavlenko --- client/client.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/client.go b/client/client.go index 2c35b07b1..c73cccaaf 100644 --- a/client/client.go +++ b/client/client.go @@ -21,11 +21,14 @@ import ( "context" "encoding/json" "fmt" + "runtime" "strconv" "strings" "sync" "time" + "google.golang.org/grpc/resolver" + containersapi "github.com/containerd/containerd/api/services/containers/v1" diffapi "github.com/containerd/containerd/api/services/diff/v1" imagesapi "github.com/containerd/containerd/api/services/images/v1" @@ -79,6 +82,14 @@ func init() { typeurl.Register(&specs.LinuxResources{}, prefix, "opencontainers/runtime-spec", major, "LinuxResources") typeurl.Register(&specs.WindowsResources{}, prefix, "opencontainers/runtime-spec", major, "WindowsResources") typeurl.Register(&features.Features{}, prefix, "opencontainers/runtime-spec", major, "features", "Features") + + if runtime.GOOS == "windows" { + // After bumping GRPC to 1.64, Windows tests started failing with: "name resolver error: produced zero addresses". + // This is happening because grpc.NewClient uses DNS resolver by default, which apparently not what we want + // when using socket paths on Windows. + // Using a workaround from https://github.com/grpc/grpc-go/issues/1786#issuecomment-2119088770 + resolver.SetDefaultScheme("passthrough") + } } // New returns a new containerd client that is connected to the containerd