Skip to content

upstream: fix: set MaxIdleConnsPerHost on internal HTTP transports (goharbor/harbor#23591) - #533

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
upstream/cherry-pick-23591-c2c27ed2d
Draft

upstream: fix: set MaxIdleConnsPerHost on internal HTTP transports (goharbor/harbor#23591)#533
github-actions[bot] wants to merge 1 commit into
mainfrom
upstream/cherry-pick-23591-c2c27ed2d

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

This cherry-pick had conflicts and was opened as a draft. Conflict markers may be present in the diff and must be resolved before marking ready for review.

Summary

Cherry-picks upstream Harbor commit c2c27ed2d from goharbor/harbor#23591.

Upstream Context

Cherry-Pick Status

Upstream Description

Comprehensive Summary

Go's http.Transport defaults MaxIdleConnsPerHost to 2. Harbor's internal traffic is dominated by single-host hotspots (core → registry reverse proxy, registry API client, jobservice → core hooks, scanner adapter client), so under high concurrency almost every connection is closed after use. The resulting churn piles up client-side TIME_WAIT sockets and eventually exhausts ephemeral ports:

http: proxy error: dial tcp 172.18.0.4:5000: connect: cannot assign requested address

Changes:

  • common/http/transport.go: newDefaultTransport() now sets MaxIdleConns=1000 / MaxIdleConnsPerHost=200, covering the registry client, core↔jobservice, webhook jobs and replication adapters.
  • server/registry/proxy.go: the core → registry reverse proxy previously fell back to http.DefaultTransport when internal TLS is disabled; it now always gets a dedicated transport with MaxIdleConns(PerHost)=1024, as all /v2/ data-plane traffic targets a single host.
  • jobservice/hook/hook_client.go / pkg/scan/rest/v1/client.go: per-host idle pool now matches MaxIdleConns (20/100), since each client only talks to one endpoint.

These knobs only enable connection reuse — idle connections beyond actual need are still reaped by IdleConnTimeout, and peak connection count remains driven by concurrency. No behavior change.

Issue being fixed

Observed on a docker-compose deployment under high-concurrency pulls; core floods proxy error: context canceled followed by cannot assign requested address on the core → registry hop.

Review Notes

  • Generated by the upstream cherry-pick workflow.
  • One upstream commit maps to one Harbor Next PR.
  • If this PR is closed without merge, the workflow will not recreate it.

Upstream-Commit: c2c27ed2d617eee7a53b6c130a73c06668f910c8
Upstream-PR: goharbor/harbor#23591
Cherry-Pick-Status: conflicted

…oharbor/harbor#23591)

Go's default MaxIdleConnsPerHost(2) causes heavy connection churn on
Harbor's single-host internal traffic (core->registry proxy, registry
client, jobservice hooks, scanner client), piling up TIME_WAIT sockets
and exhausting ephemeral ports under high concurrency (dial error:
cannot assign requested address).

Raise per-host idle pools to match each path's concurrency. Idle
connections are still reaped by IdleConnTimeout; no behavior change.

Signed-off-by: chlins <chlins.zhang@gmail.com>
Co-authored-by: Wang Yan <wangyan_0219@hotmail.com>

(cherry picked from commit c2c27ed2d617eee7a53b6c130a73c06668f910c8)

Upstream-Commit: c2c27ed2d617eee7a53b6c130a73c06668f910c8
Upstream-PR: goharbor/harbor#23591
Upstream-Author: @chlins
Cherry-Pick-Status: conflicted
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

0 participants