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

Close metric family channel in case of errors #70

Merged

Conversation

annismckenzie
Copy link
Contributor

FetchMetricFamilies never closes the channel if the request fails or can't be constructed correctly (lines 153, 160 and 165). In these cases ch is never closed and the caller will probably leak a goroutine when used as a library. This fix doesn't break backwards compatibility.

We can't add a defer close(ch) in line 150 because ParseResponse itself also closes the channel.

@beorn7 beorn7 self-requested a review November 13, 2019 12:44
@beorn7
Copy link
Member

beorn7 commented Nov 13, 2019

Oops, good point. I'll have a closer look ASAP. (Perhaps there is also a way to solve it more elegantly. But not breaking current users is also a good thing.)

@annismckenzie
Copy link
Contributor Author

Oops, good point. I'll have a closer look ASAP. (Perhaps there is also a way to solve it more elegantly. But not breaking current users is also a good thing.)

Thanks for the quick response! 💃

Copy link
Member

@beorn7 beorn7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, let's go for this approach. However, I need you to add the DCO line to the commit message.
(Run git commit --amend -s in your branch and then force-push.)

@beorn7
Copy link
Member

beorn7 commented Nov 25, 2019

And sorry for the long delay. It was a busy week at KubeCon + CloudNativeCon.

`FetchMetricFamilies` fails to close the channel if the request fails
or can't be constructed correctly (lines 154, 160 and 164). In these
cases `ch` is never closed and the caller will probably leak a goroutine
when used as a library. This fix doesn't break backwards compatibility.

Signed-off-by: Daniel Lohse <daniel.lohse@alfatraining.de>
@annismckenzie
Copy link
Contributor Author

And sorry for the long delay. It was a busy week at KubeCon + CloudNativeCon.

No need to apologize, we're good.

OK, let's go for this approach. However, I need you to add the DCO line to the commit message.
(Run git commit --amend -s in your branch and then force-push.)

That's done.

@beorn7 beorn7 merged commit 62ab843 into prometheus:master Nov 26, 2019
@annismckenzie annismckenzie deleted the fix-metric-family-channel-close branch November 26, 2019 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants