Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thevilledev
Copy link
Collaborator

1. Why is this pull request needed and what does it do?

DNS-over-HTTPS implementation used context.Background() instead of the HTTP request context when calling ServeDNS(). This broke timeout propagation and cancellation, causing DNS processing to continue even after HTTP clients disconnected or timed out. With this change, the original HTTP request context is used as the base context.

Add a test for validation. These tests also cover how the HTTP request metadata can be accessed through the context in plugins. If you run the test against master branch you'll see that the test fails:

--- FAIL: TestHTTPRequestContextPropagation (0.00s)
    --- FAIL: TestHTTPRequestContextPropagation/context_cancellation_propagation (0.00s)
        server_https_test.go:205: Context cancellation was not detected in plugin
        server_https_test.go:209: Expected context to be cancelled, but it wasn't
    --- FAIL: TestHTTPRequestContextPropagation/context_timeout_propagation (0.00s)
        server_https_test.go:227: Expected context to have a deadline

Update documentation about context use in plugin development.

2. Which issues (if any) are related?

None found. However, the broken timeout/cancellation behavior may have caused all kinds of issues. This has been in the codebase since #1619 or CoreDNS v1.1.3 (May 2018).

3. Which documentation changes (if any) need to be made?

I added a note to plugin.md about what kind of transport related information is available through the context.

4. Does this introduce a backward incompatible change or deprecation?

No breaking changes. DNS processing now properly respects HTTP request timeouts and cancellation.

Previously DNS-over-HTTPS used context.Background() instead of the
HTTP request context, breaking timeout propagation and cancellation.
With this fix, the original HTTP request context is passed forward.

Adds a test for validation.

Update documentation about context use in plugin development.

Signed-off-by: Ville Vesilehto <[email protected]>
@thevilledev thevilledev force-pushed the fix/http-context-propagation branch from 3a639e5 to 47b149b Compare August 30, 2025 13:15
@codecov
Copy link

codecov bot commented Aug 30, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.07%. Comparing base (93c57b6) to head (47b149b).
⚠️ Report is 1611 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7491      +/-   ##
==========================================
+ Coverage   55.70%   60.07%   +4.36%     
==========================================
  Files         224      274      +50     
  Lines       10016    18147    +8131     
==========================================
+ Hits         5579    10901    +5322     
- Misses       3978     6610    +2632     
- Partials      459      636     +177     

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

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

@yongtang yongtang merged commit abef207 into coredns:master Sep 2, 2025
13 checks passed
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.

2 participants