-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Error handling for docker swarm mode #1533
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tanyadegurechaff
You introduced a memory leak (you need to close the new channel).
Could you explain in details how your code fixes the issue? Isn't this issue Swarm related instead ?
Ping @vdemeester
This makes backoff operation return error when an error occurs, and the operation will be retried. |
Could you explain in detail how a memory leak comes about? |
AFAIK not closing a channel does not introduce a memory leak by itself (as one could worry in regards to files). As I see it's just a mechanism for communicating that nothing more will be sent there, right? (I'd really like to know if I got something wrong). |
@tanyadegurechaff @beldpro-ci After reading more in details, indeed, it does not introduce any memory leak in this case. But it is still better to defer close the channel, especially because it's inside a go routine. We had many leaks in the past due to opened channels. Other than that, seems great :) |
Thank you for your feedbacks. @beldpro-ci @emilevauge |
// TODO: This need to be change. Linked to Swarm events docker/docker#23827 | ||
ticker := time.NewTicker(SwarmDefaultWatchTime) | ||
pool.Go(func(stop chan bool) { | ||
defer close(errChan) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you put the defer here?
I think you must move this line under the line 156.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The receiver at line 185 blocks the execution until the channel is closed or received an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @tanyadegurechaff on this. But it would be better to use this syntax instead:
if err, ok := <-errChan; ok {
return err
} else {
// channel closed
...
}
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I got an error from golint:
provider/docker/docker.go:187:13: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just do:
if err, ok := <-errChan; ok {
return err
}
// channel closed
// ...
Due to SemaphoreCI, I close and reopen the PR. |
01127f9
to
f5e878a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @tanyadegurechaff
LGTM !
Description
Fixes #1100