diff --git a/pkg/daemons/executor/executor.go b/pkg/daemons/executor/executor.go index c8ff45aaff24..e59b81ea99b8 100644 --- a/pkg/daemons/executor/executor.go +++ b/pkg/daemons/executor/executor.go @@ -37,6 +37,7 @@ type ETCDConfig struct { InitialOptions `json:",inline"` Name string `json:"name,omitempty"` ListenClientURLs string `json:"listen-client-urls,omitempty"` + ListenClientHTTPURLs string `json:"listen-client-http-urls,omitempty"` ListenMetricsURLs string `json:"listen-metrics-urls,omitempty"` ListenPeerURLs string `json:"listen-peer-urls,omitempty"` AdvertiseClientURLs string `json:"advertise-client-urls,omitempty"` diff --git a/pkg/etcd/etcd.go b/pkg/etcd/etcd.go index 249ea4d0c51c..7fc7458634ae 100644 --- a/pkg/etcd/etcd.go +++ b/pkg/etcd/etcd.go @@ -834,6 +834,14 @@ func (e *ETCD) listenMetricsURLs(reset bool) string { return metricsURLs } +// listenClientHTTPURLs returns a list of URLs to bind to for http client connections. +// This should no longer be used, but we must set it in order to free the listen URLs +// for dedicated use by GRPC. +// Ref: https://github.com/etcd-io/etcd/issues/15402 +func (e *ETCD) listenClientHTTPURLs() string { + return fmt.Sprintf("https://%s:2382", e.config.Loopback(true)) +} + // cluster calls the executor to start etcd running with the provided configuration. func (e *ETCD) cluster(ctx context.Context, reset bool, options executor.InitialOptions) error { ctx, e.cancel = context.WithCancel(ctx) @@ -864,6 +872,7 @@ func (e *ETCD) cluster(ctx context.Context, reset bool, options executor.Initial Logger: "zap", LogOutputs: []string{"stderr"}, ExperimentalInitialCorruptCheck: true, + ListenClientHTTPURLs: e.listenClientHTTPURLs(), }, e.config.ExtraEtcdArgs) } @@ -885,10 +894,16 @@ func (e *ETCD) StartEmbeddedTemporary(ctx context.Context) error { endpoints := getEndpoints(e.config) clientURL := endpoints[0] + // peer URL is usually 1 more than client peerURL, err := addPort(endpoints[0], 1) if err != nil { return err } + // client http URL is usually 3 more than client, after peer and metrics + clientHTTPURL, err := addPort(endpoints[0], 3) + if err != nil { + return err + } embedded := executor.Embedded{} ctx, e.cancel = context.WithCancel(ctx) @@ -898,6 +913,7 @@ func (e *ETCD) StartEmbeddedTemporary(ctx context.Context) error { ForceNewCluster: true, AdvertiseClientURLs: clientURL, ListenClientURLs: clientURL, + ListenClientHTTPURLs: clientHTTPURL, ListenPeerURLs: peerURL, Logger: "zap", HeartbeatInterval: 500,