Skip to content
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

Merged
merged 2 commits into from
Dec 14, 2018
Merged

Run stop logic only if required #5144

merged 2 commits into from
Dec 14, 2018

Conversation

glinton
Copy link
Contributor

@glinton glinton commented Dec 14, 2018

Resolves #5143

@glinton glinton added this to the 1.9.2 milestone Dec 14, 2018
@glinton glinton added the fix pr to fix corresponding bug label Dec 14, 2018
p.wg.Wait()
if p.MonitorPods {
p.cancel()
p.wg.Wait()
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

@danielnelson danielnelson merged commit 891eff0 into master Dec 14, 2018
@danielnelson danielnelson deleted the bugfix/5143 branch December 14, 2018 22:34
danielnelson pushed a commit that referenced this pull request Dec 14, 2018
trevorwhitney pushed a commit to trevorwhitney/telegraf that referenced this pull request Feb 14, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
otherpirate pushed a commit to otherpirate/telegraf that referenced this pull request Mar 15, 2019
dupondje pushed a commit to dupondje/telegraf that referenced this pull request Apr 22, 2019
bitcharmer pushed a commit to bitcharmer/telegraf that referenced this pull request Oct 18, 2019
athoune pushed a commit to bearstech/telegraf that referenced this pull request Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix pr to fix corresponding bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants