Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils: let http client can reuse connections #7048

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/utils/etcdutil/etcdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,16 @@ func CreateEtcdClient(tlsConfig *tls.Config, acURL url.URL) (*clientv3.Client, e
}

func createHTTPClient(tlsConfig *tls.Config) *http.Client {
return &http.Client{
Transport: &http.Transport{
DisableKeepAlives: true,
TLSClientConfig: tlsConfig,
},
// FIXME: Currently, there is no timeout set for certain requests, such as GetRegions,
// which may take a significant amount of time. However, it might be necessary to
// define an appropriate timeout in the future.
cli := &http.Client{}
if tlsConfig != nil {
transport := http.DefaultTransport.(*http.Transport).Clone()
transport.TLSClientConfig = tlsConfig
cli.Transport = transport
}
return cli
}

// InitClusterID creates a cluster ID for the given key if it hasn't existed.
Expand Down
Loading