-
Notifications
You must be signed in to change notification settings - Fork 712
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
probes leak two goroutines when closing attach/exec window #1767
Comments
We had ws related leaks in the app before - see #1189. But I could not find any previous reports of leaks in the probe. |
This patch to go-dockerclient fixes this: diff --git a/vendor/github.com/fsouza/go-dockerclient/client.go b/vendor/github.com/fsouza/go-dockerclient/client.go
index 3941157..150d4c8 100644
--- a/vendor/github.com/fsouza/go-dockerclient/client.go
+++ b/vendor/github.com/fsouza/go-dockerclient/client.go
@@ -676,7 +676,7 @@ func (c *Client) hijack(method, path string, hijackOptions hijackOptions) (Close
}
}
- errs := make(chan error)
+ errs := make(chan error, 1)
quit := make(chan struct{})
go func() {
clientconn := httputil.NewClientConn(dial, nil)
@@ -690,7 +690,7 @@ func (c *Client) hijack(method, path string, hijackOptions hijackOptions) (Close
defer rwc.Close()
errChanOut := make(chan error, 1)
- errChanIn := make(chan error, 1)
+ errChanIn := make(chan error, 2)
if hijackOptions.stdout == nil && hijackOptions.stderr == nil {
close(errChanOut)
} else {
@@ -740,14 +740,12 @@ func (c *Client) hijack(method, path string, hijackOptions hijackOptions) (Close
select {
case errIn = <-errChanIn:
case <-quit:
- return
}
var errOut error
select {
case errOut = <-errChanOut:
case <-quit:
- return
}
if errIn != nil { The problem is two-fold:
@tomwilkie I see you worked on this code in fsouza/go-dockerclient#432. Looks like both issues were introduced there. Would you mind checking my analysis and fix above? |
I am going to create a PR to go-dockerclient with the patch above |
TBH I don't see why the two selects can't be merged at the end, which would remove the need for the |
They can't since we need to do one read from |
To include fsouza/go-dockerclient#562 , which fixes #1767
Step to reproduce:
scope launch
docker logs -f weavescope |& grep "goroutine"
kill -QUIT pid
Observe that the number of goroutines has increased by 2x the number of times step 4 has been repeated.
The leaked goroutines look like this:
AFAIK we get one of the first two, and the last.
These goroutines appear to stick around forever - they were still there after ten minutes.
Note that the app does not appear to leak any goroutines when doing this. And no file descriptors appear to leak from either the probe or app.
The text was updated successfully, but these errors were encountered: