Fix etcd egress dialer addr parsing

This commit is contained in:
Jordan Liggitt 2021-06-14 18:02:59 -04:00
parent 19db126d76
commit a26c392de1

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))
}