[UNDERTOW-1880] Graceful shutdown of HTTP/2 server using GOAWAY#1906
[UNDERTOW-1880] Graceful shutdown of HTTP/2 server using GOAWAY#1906fl4via wants to merge 6 commits intoundertow-io:mainfrom
Conversation
…SinkChannel When a channel is flushed a frame can decide that it's the final frame, triggering the channel to be closed. Previously all GOAWAY frames were final frames, but during a graceful shutdown there is a need to be able to send multiple GOAWAY frames without closing the channel. Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech> Signed-off-by: Flavia Rainone <frainone@redhat.com>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech> Signed-off-by: Flavia Rainone <frainone@redhat.com>
… GOAWAY Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech> Signed-off-by: Flavia Rainone <frainone@redhat.com>
Use tracked HTTP/2 channels in GracefulShutdownHandler to initate a graceful shutdown using GOAWAY according to RFC7540 6.8. - Send initial GOAWAY with last stream id set to 2^31-1 - Send an updated GOAWAY with updated last stream id after 1 sec - Force close if client has not already disconnected after 3 sec Http/2 requests will be handled during the graceful shutdown, but http/1 will be rejected with `503 Service Unavailable` awaitShutdown() waits for both ongoing requests to finish and for active HTTP/2 connections to be closed by the client. Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech> Signed-off-by: Flavia Rainone <frainone@redhat.com>
In addition to `suspend/resume of accepting new clients` its now also possible
to stop listening for new clients, i.e the listening socket will be closed.
This is needed when performing a graceful shutdown to avoid that clients just
reconnects via a new socket.
A code example of a graceful shutdown:
// Stop listening for new client connections
List<ListenerInfo> listeners = server.getListenerInfo();
for (ListenerInfo listener : listeners) {
listener.stop();
}
// Trigger a graceful shutdown of existing connections
shutdownHandler.shutdown();
// Wait for the graceful shutdown to finish
shutdownHandler.awaitShutdown(6000);
// Forceful shutdown of server
server.stop();
Signed-off-by: Flavia Rainone <frainone@redhat.com>
Signed-off-by: Björn Svensson <bjorn.a.svensson@est.tech> Signed-off-by: Flavia Rainone <frainone@redhat.com>
|
@bjosv , to not let your code be forgotten, I created a new PR. And we will be doing a PR burn down right after Beta1 is released, for Beta2. |
@fl4via I had some time to investigate it now and created fl4via#2 on to your branch. All tests seems to pass now when running |
Jira:
https://issues.redhat.com/browse/UNDERTOW-1880
Follows up #1140 and #1905, for investigation of broken test