The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2480
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === http/transport.go says: // By default, Transport caches connections for future re-use. // This may leave many open connections when accessing many hosts. // This behavior can be managed using Transport's CloseIdleConnections // method // and the MaxIdleConnsPerHost and DisableKeepAlives fields. In particular, babbageclunk | Yeah - we end up leaking 10 goroutines everytime we destroy a model. juju uses the client from a long running daemon, which creates a new http.Transport for each call to the API, which creates a new http.Transport, which leaks these goroutines. Perhaps we can fix this more better with the client rewrite, but for now let's just not do the keepalive, since that's how we're using http.Transport anyway. Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From 87c0b9df6c52259586b392c41cdeeffbcbabd286 Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Tue, 11 Oct 2016 09:00:19 -0600 Subject: [PATCH] disable keepalives in http.Transports http/transport.go says: // By default, Transport caches connections for future re-use. // This may leave many open connections when accessing many hosts. // This behavior can be managed using Transport's CloseIdleConnections // method // and the MaxIdleConnsPerHost and DisableKeepAlives fields. In particular, babbageclunk | Yeah - we end up leaking 10 goroutines everytime we destroy a model. juju uses the client from a long running daemon, which creates a new http.Transport for each call to the API, which creates a new http.Transport, which leaks these goroutines. Perhaps we can fix this more better with the client rewrite, but for now let's just not do the keepalive, since that's how we're using http.Transport anyway. Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- client.go | 12 ++++++++---- lxd/daemon.go | 14 ++++++++------ 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/client.go b/client.go index 2b08baa..4309cb6 100644 --- a/client.go +++ b/client.go @@ -272,7 +272,10 @@ func connectViaUnix(c *Client, remote *RemoteConfig) error { } return net.DialUnix("unix", nil, raddr) } - c.Http.Transport = &http.Transport{Dial: uDial} + c.Http.Transport = &http.Transport{ + Dial: uDial, + DisableKeepAlives: true, + } c.websocketDialer.NetDial = uDial c.Remote = remote @@ -291,9 +294,10 @@ func connectViaHttp(c *Client, remote *RemoteConfig, clientCert, clientKey, clie } tr := &http.Transport{ - TLSClientConfig: tlsconfig, - Dial: shared.RFC3493Dialer, - Proxy: shared.ProxyFromEnvironment, + TLSClientConfig: tlsconfig, + Dial: shared.RFC3493Dialer, + Proxy: shared.ProxyFromEnvironment, + DisableKeepAlives: true, } c.websocketDialer.NetDial = shared.RFC3493Dialer diff --git a/lxd/daemon.go b/lxd/daemon.go index c60ad6c..949d7dc 100644 --- a/lxd/daemon.go +++ b/lxd/daemon.go @@ -129,9 +129,10 @@ func (d *Daemon) httpGetSync(url string, certificate string) (*lxd.Response, err } tr := &http.Transport{ - TLSClientConfig: tlsConfig, - Dial: shared.RFC3493Dialer, - Proxy: d.proxy, + TLSClientConfig: tlsConfig, + Dial: shared.RFC3493Dialer, + Proxy: d.proxy, + DisableKeepAlives: true, } myhttp := http.Client{ @@ -184,9 +185,10 @@ func (d *Daemon) httpGetFile(url string, certificate string) (*http.Response, er } tr := &http.Transport{ - TLSClientConfig: tlsConfig, - Dial: shared.RFC3493Dialer, - Proxy: d.proxy, + TLSClientConfig: tlsConfig, + Dial: shared.RFC3493Dialer, + Proxy: d.proxy, + DisableKeepAlives: true, } myhttp := http.Client{ Transport: tr,
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel