Fix etcd egress dialer addr parsing

Kubernetes-commit: a26c392de176494f2c425f712bc49fc399e9ce6d
This commit is contained in:
Jordan Liggitt 2021-06-14 18:02:59 -04:00 committed by Kubernetes Publisher
parent aaf5f32453
commit 2f8b9e4dbc
1 changed files with 9 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import (
"net"
"net/url"
"path"
"strings"
"sync"
"sync/atomic"
"time"
@ -137,11 +138,15 @@ func newETCD3Client(c storagebackend.TransportConfig) (*clientv3.Client, error)
}
if egressDialer != nil {
dialer := func(ctx context.Context, addr string) (net.Conn, error) {
u, err := url.Parse(addr)
if err != nil {
return nil, err
if strings.Contains(addr, "//") {
// etcd client prior to 3.5 passed URLs to dialer, normalize to address
u, err := url.Parse(addr)
if err != nil {
return nil, err
}
addr = u.Host
}
return egressDialer(ctx, "tcp", u.Host)
return egressDialer(ctx, "tcp", addr)
}
dialOptions = append(dialOptions, grpc.WithContextDialer(dialer))
}