-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Run stop logic only if required #5144
Conversation
p.wg.Wait() | ||
if p.MonitorPods { | ||
p.cancel() | ||
p.wg.Wait() |
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.
Always need to wait, if metrics are added after Stop is called the channel could be closed.
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.
Even if p.wg
is only utilized if MonitorPods
is set?
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 believe WaitGroup is always used, otherwise I would say no. Another option here that @goller mentioned was the null object pattern with cancel normally set to func() {}
. This way you could always wait and wouldn't need to line up the booleans.
(cherry picked from commit 891eff0)
Resolves #5143