Skip to content

http3: close QUIC listeners created by Server on graceful shutdown#5101

Merged
marten-seemann merged 1 commit intomasterfrom
graceful-shutdown-listener-close
May 8, 2025
Merged

http3: close QUIC listeners created by Server on graceful shutdown#5101
marten-seemann merged 1 commit intomasterfrom
graceful-shutdown-listener-close

Conversation

@marten-seemann
Copy link
Copy Markdown
Member

Fixes #5099.

@marten-seemann marten-seemann requested a review from Copilot April 30, 2025 10:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves graceful shutdown behavior for QUIC listeners in the HTTP/3 server by distinguishing between listeners created internally and those supplied by the application.

  • Introduces a new boolean field, createdByApp, in the listener struct.
  • Updates addListener calls to set the createdByApp flag based on the listener’s origin.
  • Modifies the Shutdown method’s documentation and closing logic for QUIC listeners.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 30, 2025

Codecov Report

Attention: Patch coverage is 27.27273% with 8 lines in your changes missing coverage. Please review.

Project coverage is 84.20%. Comparing base (8296ba7) to head (30bdc6e).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
http3/server.go 27.27% 6 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5101      +/-   ##
==========================================
- Coverage   84.24%   84.20%   -0.04%     
==========================================
  Files         153      153              
  Lines       17235    17245      +10     
==========================================
+ Hits        14518    14520       +2     
- Misses       2165     2171       +6     
- Partials      552      554       +2     

☔ 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.

@marten-seemann marten-seemann force-pushed the graceful-shutdown-listener-close branch from 76b2578 to bd3136d Compare May 6, 2025 04:18
@marten-seemann marten-seemann requested a review from Copilot May 6, 2025 04:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes #5099 by ensuring that only the appropriate QUIC listeners are closed during a graceful shutdown.

  • Introduces a new flag in the listener struct to mark if the listener was created externally.
  • Updates addListener calls to pass the new flag based on the context of listener creation.
  • Changes the shutdown procedure to conditionally close listeners based on the new flag.

@marten-seemann marten-seemann force-pushed the graceful-shutdown-listener-close branch from bd3136d to e1f0792 Compare May 6, 2025 04:29
@marten-seemann marten-seemann requested a review from Copilot May 6, 2025 05:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the QUIC listener shutdown behavior to ensure that only the listeners created by the Server (internally) are closed on graceful shutdown while leaving application-constructed listeners untouched.

  • Introduces a new flag (createdLocally) in the listener struct.
  • Modifies addListener() to accept the createdLocally parameter based on where the listener is created.
  • Updates Shutdown() to close only server-created listeners.
Comments suppressed due to low confidence (1)

http3/server.go:97

  • [nitpick] The comment on the 'createdLocally' field is a bit ambiguous. Since the flag is true for listeners created by the Server (which are intended to be closed on shutdown) and false for application-provided listeners, please clarify the comment to something like: 'If true, indicates that the listener was created by the Server and will be closed during graceful shutdown; if false, it was provided by the application and will remain open.'
// If this listener was constructed by the application, graceful shutdown will not close it.

@marten-seemann marten-seemann force-pushed the graceful-shutdown-listener-close branch 2 times, most recently from 20b1197 to 342b012 Compare May 7, 2025 12:14
@marten-seemann marten-seemann marked this pull request as ready for review May 7, 2025 12:15
@marten-seemann marten-seemann requested a review from Copilot May 7, 2025 12:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes graceful shutdown behavior by ensuring that only QUIC listeners created internally by the http3.Server are closed on shutdown, while externally provided application listeners remain open.

  • Added new tests in integrationtests/self/http_shutdown_test.go and http3/server_test.go to verify graceful shutdown behavior.
  • Updated addListener, Close, and Shutdown methods in http3/server.go to track and act on whether a listener was created internally.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
integrationtests/self/http_shutdown_test.go Added tests to differentiate behavior between application-created listeners and those created by the http3.Server.
http3/server_test.go Introduced immediate graceful shutdown test to validate shutdown behavior.
http3/server.go Updated listener handling to include a createdLocally flag and adjusted shutdown/close logic accordingly.

@marten-seemann marten-seemann force-pushed the graceful-shutdown-listener-close branch from 342b012 to 30bdc6e Compare May 8, 2025 06:04
@marten-seemann marten-seemann requested a review from Copilot May 8, 2025 06:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses the graceful shutdown of the HTTP3 server by ensuring that QUIC listeners created locally are properly closed during shutdown, which fixes issue #5099. Key changes include:

  • Updating test functions to distinguish between graceful and non‐graceful shutdown scenarios.
  • Adjusting the number of repeated connection attempts in the test.
  • Altering the Shutdown method in the HTTP3 server to iterate and close locally created listeners.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
integrationtests/self/http_shutdown_test.go Refactored test functions and adjusted parameters/iterations for shutdown testing.
http3/server.go Modified Shutdown to close only locally created listeners and return joined errors.
Comments suppressed due to low confidence (1)

integrationtests/self/http_shutdown_test.go:211

  • [nitpick] Consider using a consistent naming convention for test functions and helper functions. The mix of 'TestHTTP3ListenerGracefulShutdown' (a top-level test) and 'testHTTP3ListenerClosing' (a helper) might be confusing; a more distinct naming can clarify their purposes.
func TestHTTP3ListenerGracefulShutdown(t *testing.T) {

@marten-seemann marten-seemann merged commit 1725cb0 into master May 8, 2025
38 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.

http3: server needs to close QUIC listeners when graceful shutdown is initiated

2 participants