-
-
Notifications
You must be signed in to change notification settings - Fork 177
Use channel to stop the node.Refresh() goroutine #178
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
Conversation
|
Thanks for spotting this issue, leaking goroutines can be as easy as creating them! What do you think of just doing something like this instead? n.refreshTicker.Stop()
close(n.refreshTicker.C) |
|
Yeah, that was my first thought as well but turns out, you can't close the ticker channel, it's read-only. |
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.
You could use a chan struct{} here instead. Not much difference but theres no reason not to.
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.
Kinda the same but I slightly prefer the bool chan as it somewhat better communicates the Done == true fact. No strong feelings though.
|
Oh interesting, I will give it a proper test tomorrow then. Thanks. |
|
Sounds good. |
Use channel to stop the node.Refresh() goroutine
|
@oliver006 Pardon the intrusion - what user interface is that screenshot from? |
|
@kofalt - no worries. The data is collected via Prometheus and the UI is PromDash |

Unfortunately,
refreshTicker.Stop()doesn't close the refreshTicker channel so the goroutines refreshing the node status don't ever exit and goroutines start accumulating every time you open a new session to a cluster.This PR changes the code to use a bool chan instead of the ticker channel.