From e774b46f822fefc487b946a5baf000c210da42ab Mon Sep 17 00:00:00 2001 From: Frank Schroeder Date: Thu, 26 Oct 2017 11:57:18 +0200 Subject: [PATCH] docker: close idle connections on stop --- agent/checks/check.go | 1 + agent/checks/docker.go | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/agent/checks/check.go b/agent/checks/check.go index 446521021a..87e2c904b8 100644 --- a/agent/checks/check.go +++ b/agent/checks/check.go @@ -573,6 +573,7 @@ func (c *CheckDocker) Stop() { } func (c *CheckDocker) run() { + defer c.Client.Close() firstWait := lib.RandomStagger(c.Interval) next := time.After(firstWait) for { diff --git a/agent/checks/docker.go b/agent/checks/docker.go index c3cddd646b..c703cb0cb5 100644 --- a/agent/checks/docker.go +++ b/agent/checks/docker.go @@ -54,6 +54,13 @@ func NewDockerClient(host string, maxbuf int64) (*DockerClient, error) { }, nil } +func (c *DockerClient) Close() error { + if t, ok := c.client.Transport.(*http.Transport); ok { + t.CloseIdleConnections() + } + return nil +} + func (c *DockerClient) Host() string { return c.host }