Skip to content

fix(backend): set the connect timeout of the http client - #2202

Merged
gaius-qi merged 3 commits into
mainfrom
fix/backend-connect-timeout
Dec 2, 2026
Merged

gaius-qi merged 3 commits into
mainfrom
fix/backend-connect-timeout

Conversation

@chlins

@chlins chlins commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Description

Set a 5s connect timeout on both reqwest clients of the http backend (the default one and the one for the client certificate). Same as the proxy's DEFAULT_PROXY_TIMEOUT.

Add a test that stats a server with a full accept queue. It took 30s before and 5s after.

Related Issue

dragonflyoss/dragonfly#5116

Motivation and Context

Without a connect timeout, the source stat in Task::download_started waits for the kernel SYN retries (about 127s) when the registry is unreachable. containerd gives up after 30s (ResponseHeaderTimeout), so the proxy never falls back to the parents and the pull fails even though the peers have the image.

Found in an e2e test with the network to the registry dropping every packet. A registry that accepts the connection and never answers is not covered here.

The http backend had no connect timeout, so the source stat waited for the
kernel SYN retries (about 127s) when the source was unreachable, longer than
containerd waits (30s), and the proxy never fell back to the parents.

Signed-off-by: Chlins Zhang <chlins.zhang@gmail.com>
@chlins
chlins force-pushed the fix/backend-connect-timeout branch from 7b2f7d3 to 5078c2e Compare December 1, 2026 08:47
@chlins chlins added the enhancement New feature or request label Dec 1, 2026
@codecov

codecov Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.08%. Comparing base (8c1ce13) to head (5b053e3).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2202      +/-   ##
==========================================
- Coverage   67.09%   67.08%   -0.01%     
==========================================
  Files         102      102              
  Lines       33018    33060      +42     
==========================================
+ Hits        22152    22177      +25     
- Misses      10866    10883      +17     
Files with missing lines Coverage Δ
dragonfly-client-backend/src/http.rs 97.89% <100.00%> (+0.08%) ⬆️
dragonfly-client-backend/src/lib.rs 94.35% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chlins

chlins commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

e2e on a 50 node cluster (scheduler with redis, manifest tag cache on), a fresh node pulls by the tag and another by the digest while the peers have the image:

Registry Before After
refuses the connection ok ok (7s / 5s)
answers 503 ok ok (5s / 4s)
drops every packet DeadlineExceeded ok (47s / 52s), registry got 0 requests
accepts and never answers DeadlineExceeded DeadlineExceeded (not covered by this PR)

Relocate `DEFAULT_CONNECT_TIMEOUT` from the HTTP backend into the
shared lib module alongside other connection-related constants, so it
can be reused across backend implementations instead of being tied to
the HTTP backend only. Update references and tests accordingly.

Signed-off-by: Gaius <gaius.qi@gmail.com>
gaius-qi
gaius-qi previously approved these changes Dec 2, 2026

@gaius-qi gaius-qi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: Chlins Zhang <chlins.zhang@gmail.com>

@gaius-qi gaius-qi left a comment

Copy link
Copy Markdown
Member

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 enabled auto-merge (squash) December 2, 2026 03:08

@BraveY BraveY left a comment

Copy link
Copy Markdown
Contributor

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 merged commit f942b98 into main Dec 2, 2026
7 checks passed
@gaius-qi
gaius-qi deleted the fix/backend-connect-timeout branch December 2, 2026 03:19
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.

3 participants