This PR fixes an issue encountered with gRPC in an IPv6 only clusters.
Current implementation
The current implementation is using fmt.Sprintf to combine the hostname and port number used when calling grpc.Dial(...). See daemon/grpcwire/grpcwire.go for instance.
Yet, this yields the following (important part highlighted) when doing kubectl describe pod/<podName>:
Warning FailedCreatePodSandBox 10m kubelet Failed to create pod sandbox: rpc error: code = Unknown desc = failed to setup network for sandbox "ae67dda14b109f585fd51fdde5f54087955ae7b5f91d563957dbbe85a72ce021": plugin type="meshnet" name="meshnet" failed (add): rpc error: code = Unavailable desc = connection error: desc = "transport: Error while dialing dial tcp: address fc00:f853:ccd:e793::4:51111: too many colons in address"
Fix
The solution is to use Go's net.JoinHostPort(...) instead of fmt.Sprintf to combine the hostname and port number.
This method will automatically add [] around the hostname when it's an IPv6, which is using :.
Hi,
This PR fixes an issue encountered with gRPC in an IPv6 only clusters.
Current implementation
The current implementation is using
fmt.Sprintf
to combine the hostname and port number used when callinggrpc.Dial(...)
. See daemon/grpcwire/grpcwire.go for instance.Yet, this yields the following (important part highlighted) when doing
kubectl describe pod/<podName>
:Fix
The solution is to use Go's
net.JoinHostPort(...)
instead offmt.Sprintf
to combine the hostname and port number.This method will automatically add
[]
around the hostname when it's an IPv6, which is using:
.See grpc-go issue 3399 for more details.
Test
The fix has been tested on the following:
kind version
=> kind v0.20.0 go1.21.4 linux/amd64