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

feat: reuse connections and limit the number of connections for preheating #3683

Merged
merged 1 commit into from
Dec 6, 2024

Conversation

gaius-qi
Copy link
Member

@gaius-qi gaius-qi commented Dec 6, 2024

Description

This pull request introduces several improvements to the manager/job/preheat.go file, primarily focusing on enhancing the HTTP client configuration and refactoring the code for better maintainability.

HTTP Client Configuration Improvements:

  • Introduced a new defaultHTTPTransport variable to define the default HTTP transport settings, including maximum idle connections, maximum connections per host, and idle connection timeout.
  • Modified the preheat struct to include an httpClient field, and updated the newPreheat function to initialize this client with the defaultHTTPTransport settings.
  • Updated the getImageLayers method to use the httpClient from the preheat struct instead of creating a new HTTP client each time.

Code Refactoring:

  • Refactored the newImageAuthClient function to use the defaultHTTPTransport for its HTTP client, ensuring consistent transport settings across different parts of the codebase.

Related Issue

Fixed #3635.

Motivation and Context

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation Update (if none of the other choices apply)

Checklist

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.

@gaius-qi gaius-qi added the enhancement New feature or request label Dec 6, 2024
@gaius-qi gaius-qi added this to the v2.2.0 milestone Dec 6, 2024
@gaius-qi gaius-qi self-assigned this Dec 6, 2024
@gaius-qi gaius-qi requested a review from a team as a code owner December 6, 2024 03:00
CormickKneey
CormickKneey previously approved these changes Dec 6, 2024
chlins
chlins previously approved these changes Dec 6, 2024
Copy link
Member

@chlins chlins left a comment

Choose a reason for hiding this comment

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

lgtm

@gaius-qi gaius-qi dismissed stale reviews from chlins and CormickKneey via 5c96d25 December 6, 2024 03:15
Copy link

codecov bot commented Dec 6, 2024

Codecov Report

Attention: Patch coverage is 62.96296% with 10 lines in your changes missing coverage. Please review.

Project coverage is 35.33%. Comparing base (a97584a) to head (65e9cd3).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
manager/job/preheat.go 62.96% 10 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3683      +/-   ##
==========================================
- Coverage   35.39%   35.33%   -0.06%     
==========================================
  Files         335      335              
  Lines       37631    37629       -2     
==========================================
- Hits        13318    13296      -22     
- Misses      23488    23503      +15     
- Partials      825      830       +5     
Flag Coverage Δ
unittests 35.33% <62.96%> (-0.06%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
manager/job/preheat.go 46.06% <62.96%> (-3.75%) ⬇️

... and 3 files with indirect coverage changes

@gaius-qi gaius-qi force-pushed the feature/preheat branch 2 times, most recently from 30a63aa to 31d7713 Compare December 6, 2024 06:27
@gaius-qi gaius-qi requested a review from a team as a code owner December 6, 2024 06:27
@gaius-qi gaius-qi merged commit 49ae448 into main Dec 6, 2024
27 checks passed
@gaius-qi gaius-qi deleted the feature/preheat branch December 6, 2024 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dragonfly manager connection leak
4 participants