Skip to content
This repository was archived by the owner on Jul 30, 2021. It is now read-only.

Commit 5b585a2

Browse files
authored
Merge pull request #280 from aaronlevy/fd-leak
checkpoint: re-use http client transport
2 parents 7c93f22 + 7194b47 commit 5b585a2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cmd/checkpoint/main.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,13 @@ func getLocalParentPods() (map[string]*v1.Pod, error) {
334334
return podListToParentPods(&podList), nil
335335
}
336336

337+
// Transports should be re-used and not created as needed: https://golang.org/pkg/net/http/#Transport
338+
var insecureTransport *http.Transport = &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}
339+
337340
// getLocalRunningPods uses the /runningpods/ kubelet api to retrieve the local container runtime pod state
338341
func getLocalRunningPods() (map[string]*v1.Pod, error) {
339342
// TODO(aaron): The kubelet api is currently secured by a self-signed cert. We should update this to actually verify at some point
340-
client := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}}}
343+
client := &http.Client{Transport: insecureTransport}
341344
resp, err := client.Get(kubeletAPIRunningPodsURL)
342345
if err != nil {
343346
return nil, fmt.Errorf("failed to contact kubelet pod api: %v", err)

0 commit comments

Comments
 (0)