Skip to content

Commit

Permalink
Disable HTTP on main etcd client port
Browse files Browse the repository at this point in the history
Fixes performance issue under load, ref: etcd-io/etcd#15402 and kubernetes/kubernetes#118460

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Sep 25, 2023
1 parent cae8b2b commit 8c73fd6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/daemons/executor/executor.go
Expand Up @@ -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"`
Expand Down
16 changes: 16 additions & 0 deletions pkg/etcd/etcd.go
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand All @@ -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)
Expand All @@ -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,
Expand Down

0 comments on commit 8c73fd6

Please sign in to comment.