diff --git a/clientv3/client.go b/clientv3/client.go index 3139a047efa..5dd35720a78 100644 --- a/clientv3/client.go +++ b/clientv3/client.go @@ -15,6 +15,7 @@ package clientv3 import ( + "errors" "sync" "time" @@ -25,6 +26,10 @@ import ( "github.com/coreos/etcd/pkg/transport" ) +var ( + ErrNoAvailableEndpoints = errors.New("etcdclient: no available endpoints") +) + // Client provides and manages an etcd v3 client session. type Client struct { // KV is the keyvalue API for the client's connection. @@ -182,6 +187,10 @@ func (c *Client) retryConnection(oldConn *grpc.ClientConn, err error) (*grpc.Cli // connection is established. func dialEndpointList(c *Client) (*grpc.ClientConn, error) { var err error + if len(c.Endpoints()) == 0 { + return nil, ErrNoAvailableEndpoints + } + for _, ep := range c.Endpoints() { conn, curErr := c.Dial(ep) if curErr != nil {