Add HTTP ingress drain control#5094
Draft
pcholakov wants to merge 2 commits into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why\n\nToday, HTTP ingress begins graceful shutdown only after the Restate Server process receives SIGTERM. It closes its listeners and asks existing HTTP/2 connections to stop accepting new work, but the normal shutdown path has a five-second final drain deadline. Long-running streams that remain at that point are force-cancelled.\n\nFor a rolling update, that makes the pod termination window do two jobs at once: diverting new traffic and waiting for old traffic. Under load, there may not be enough time for both.\n\n## What changes\n\nThis PR adds an explicit, runtime-local HTTP ingress drain operation. A future Kubernetes preStop hook can call it before allowing process termination:\n\n\n\nThe operation:\n\n1. Stops accepting new HTTP ingress connections/streams.\n2. Gracefully shuts down existing HTTP connections (including HTTP/2 GOAWAY behavior).\n3. Reports progress, including active requests and connections.\n4. Leaves the server process and ingress role running while existing connection work drains.\n\nThe preStop integration can therefore wait for within its own budget, and only then let SIGTERM begin the existing shutdown path. SIGTERM still retains the five-second force-cancellation deadline as the final safety net.\n\nThis does not migrate an already-running stream. Streams that outlive the eventual termination budget still need retry handling.\n\n## Safety and operator behavior\n\n- The drain state is local to the running process, monotonic (), and does not write cluster metadata.\n- requires ; it calls on that same local channel and uses the returned exact generational node ID for the drain RPC.\n- The generation fence prevents a delayed request from draining a restarted process with the same plain node ID.\n- remains available for explicitly targeted operator use.\n\n## Validation\n\n- \n- \n- \n- \n-