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

Implement graceful shutdown for http3 servers. #4407

Open
wants to merge 22 commits into
base: master
Choose a base branch
from

Conversation

WeidiDeng
Copy link
Contributor

Fix 6195 for caddy.

Copy link

@francislavoie francislavoie left a comment

Choose a reason for hiding this comment

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

Small typo

http3/client.go Outdated Show resolved Hide resolved
@WeidiDeng
Copy link
Contributor Author

WeidiDeng commented Apr 5, 2024

@marten-seemann Do you have time to take a look at this draft?

@WeidiDeng WeidiDeng marked this pull request as ready for review April 7, 2024 02:30
Copy link

codecov bot commented Apr 7, 2024

Codecov Report

Attention: Patch coverage is 43.34975% with 115 lines in your changes are missing coverage. Please review.

Project coverage is 84.29%. Comparing base (66f968b) to head (ece4a80).

❗ Current head ece4a80 differs from pull request most recent head e9e5c16. Consider uploading reports for the commit e9e5c16 to get more accurate results

Files Patch % Lines
http3/client.go 36.23% 41 Missing and 3 partials ⚠️
http3/server.go 61.17% 32 Missing and 8 partials ⚠️
http3/frames.go 0.00% 28 Missing ⚠️
http3/conn.go 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4407      +/-   ##
==========================================
- Coverage   85.15%   84.29%   -0.86%     
==========================================
  Files         154      154              
  Lines       14768    14842      +74     
==========================================
- Hits        12575    12510      -65     
- Misses       1688     1808     +120     
- Partials      505      524      +19     

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

Copy link
Member

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

Thank you for working on this @WeidiDeng!

I’ve been working on a big refactor of the http3 package (#4115, #4116, more coming), which at the end will enable HTTP datagram support, which will all be included in the next release. For proper datagram support, we’ll introduce some kind of connection and stream tracking (no PR yet), which would be helpful for this PR. I suggest we defer graceful shutdown until these PRs have landed.

http3/client.go Outdated
config: conf,
opts: opts,
dialer: dialer,
receivedGoawayID: quic.StreamID(-4),
Copy link
Member

Choose a reason for hiding this comment

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

This seems hacky. Introduce a protocol.InvalidStreamID instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I got the stream ID from rfc 9000. For different kinds of streams, the criteria for invalid id is different. I think a function that verifies ID would be better instead of a new type.

http3/frames.go Outdated Show resolved Hide resolved
http3/frames.go Show resolved Hide resolved
@@ -217,7 +218,8 @@ type Server struct {
mutex sync.RWMutex
listeners map[*QUICEarlyListener]listenerInfo

closed bool
closed bool
connections map[*quic.Connection]func()
Copy link
Member

Choose a reason for hiding this comment

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

Better: Use the tracing ID as a map key.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But the methods on the quic.Connection needs to be called. To properly stop server from accepting new streams at the grace period's end. Malicious client may attempt to open new streams even if goaway is received. Goaway itself doesn't close a connection.

# Conflicts:
#	http3/client.go
#	http3/client_test.go
#	http3/server.go
#	http3/server_test.go
# Conflicts:
#	http3/client.go
#	http3/client_test.go
#	http3/conn.go
#	http3/server.go
#	http3/server_test.go
# Conflicts:
#	http3/client_test.go
#	http3/server_test.go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delay in Caddy using changes to reverse_proxy upstream
3 participants