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

fix(metricprovider): reuse http.Transport for http.Client #3780

Merged
merged 1 commit into from
Aug 12, 2024
Merged

fix(metricprovider): reuse http.Transport for http.Client #3780

merged 1 commit into from
Aug 12, 2024

Conversation

kevinji
Copy link
Contributor

@kevinji kevinji commented Aug 9, 2024

The current code creates a new http.Transport for each http.Client that is created, which leads to a leak in TCP connections due to keep-alive.

Instead, reuse the same http.Transport between requests. According to the http.Transport docs, this is safe for concurrent use.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this is a chore.
  • The title of the PR is (a) conventional with a list of types and scopes found here, (b) states what changed, and (c) suffixes the related issues number. E.g. "fix(controller): Updates such and such. Fixes #1234".
  • I've signed my commits with DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My builds are green. Try syncing with master if they are not.
  • My organization is added to USERS.md.

The current code creates a new http.Transport for each http.Client that is
created, which leads to a leak in TCP connections due to keep-alive.

Instead, reuse the same http.Transport between requests. According to the
http.Transport docs, this is safe for concurrent use.

Signed-off-by: Kevin Ji <[email protected]>
Copy link

sonarcloud bot commented Aug 9, 2024

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Published E2E Test Results

  4 files    4 suites   3h 24m 50s ⏱️
112 tests 100 ✅  7 💤 5 ❌
456 runs  421 ✅ 28 💤 7 ❌

For more details on these failures, see this check.

Results for commit 8373787.

Copy link
Contributor

github-actions bot commented Aug 9, 2024

Published Unit Test Results

2 257 tests   2 257 ✅  2m 58s ⏱️
  128 suites      0 💤
    1 files        0 ❌

Results for commit 8373787.

Copy link

codecov bot commented Aug 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.98%. Comparing base (825a7ca) to head (8373787).
Report is 65 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3780      +/-   ##
==========================================
+ Coverage   83.97%   83.98%   +0.01%     
==========================================
  Files         161      161              
  Lines       18492    18495       +3     
==========================================
+ Hits        15528    15533       +5     
+ Misses       2100     2099       -1     
+ Partials      864      863       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zachaller zachaller merged commit 6b2ee92 into argoproj:master Aug 12, 2024
26 checks passed
@kevinji kevinji deleted the reuse-transport branch August 12, 2024 15:47
zachaller pushed a commit that referenced this pull request Aug 13, 2024
The current code creates a new http.Transport for each http.Client that is
created, which leads to a leak in TCP connections due to keep-alive.

Instead, reuse the same http.Transport between requests. According to the
http.Transport docs, this is safe for concurrent use.

Signed-off-by: Kevin Ji <[email protected]>
@zachaller zachaller added the cherry-pick-completed Used once we have cherry picked the PR to all requested releases label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick/release-1.7 cherry-pick-completed Used once we have cherry picked the PR to all requested releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants