Browse Source

fix: set grpc resolver explicitly in yandex (#3838)

use passthrough resolver to be consistent with ycsdk library, and to
work correctly in dual-stack environments until gRPC proposal A61 is
fully implemented in grpc-go

fixes #3837

Signed-off-by: Viktor Oreshkin <imselfish@stek29.rocks>
Co-authored-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
Viktor Oreshkin 1 year ago
parent
commit
267e5ea9f1
1 changed files with 10 additions and 1 deletions
  1. 10 1
      pkg/provider/yandex/common/sdk.go

+ 10 - 1
pkg/provider/yandex/common/sdk.go

@@ -57,7 +57,16 @@ func NewGrpcConnection(
 		return nil, err
 	}
 
-	return grpc.NewClient(serviceAPIEndpoint.Address,
+	// Until gRPC proposal A61 is implemented in grpc-go, default gRPC name resolver (dns)
+	// is incompatible with dualstack backends, and YC API backends are dualstack.
+	// However, if passthrough resolver is used instead, grpc-go won't do any name resolution
+	// and will pass the endpoint to net.Dial as-is, which would utilize happy-eyeballs
+	// support in Go's net package.
+	// So we explicitly set gRPC resolver to `passthrough` to match `ycsdk`s behavior,
+	// which uses `passthrough` resolver implicitly by using deprecated grpc.DialContext
+	// instead of grpc.NewClient used here
+	target := "passthrough:///" + serviceAPIEndpoint.Address
+	return grpc.NewClient(target,
 		grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig)),
 		grpc.WithKeepaliveParams(keepalive.ClientParameters{
 			Time:                time.Second * 30,