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

loki-canary: Fix resource leak when using client-side certs #6579

Merged
merged 2 commits into from
Jul 6, 2022

Conversation

chodges15
Copy link
Contributor

What this PR does / why we need it:
When running canary with client side certificates (introduced in #6310), a new http.Transport is being created for each request 🤦‍♂️. As a result, connections are left open until they timeout an hour later. This quickly causes resource exhaustion and errors like dial tcp 1.1.1.1:1111: connect: cannot assign requested address.

This change will reuse the same transport for all requests just like http.DefaultClient is reused when not using client certs.

Tested by running loki-canary for 5 days and observing with netstat a constant number of TCP connections to the querier.

@chodges15 chodges15 requested a review from a team as a code owner July 5, 2022 14:42
Copy link
Contributor

@DylanGuedes DylanGuedes left a comment

Choose a reason for hiding this comment

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

lgtm

and thanks for the follow-up

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for this! Let's please find a way to not use panic

pkg/canary/reader/reader.go Outdated Show resolved Hide resolved
@grafanabot
Copy link
Collaborator

./tools/diff_coverage.sh ../loki-main/test_results.txt test_results.txt ingester,distributor,querier,querier/queryrange,iter,storage,chunkenc,logql,loki

Change in test coverage per package. Green indicates 0 or positive change, red indicates that test coverage for a package fell.

+           ingester	0%
+        distributor	0%
+            querier	0%
+ querier/queryrange	0%
+               iter	0%
+            storage	0%
+           chunkenc	0%
+              logql	0%
+               loki	0%

Copy link
Contributor

@dannykopping dannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution @chodges15 👍

@dannykopping dannykopping merged commit c582c5a into grafana:main Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants