Repository navigation
Allow opted-in services to keep accepting during graceful shutdown - #1106
Open
CodyPubNub wants to merge 3 commits into
Open
CodyPubNub wants to merge 3 commits into
CodyPubNub wants to merge 3 commits into
Conversation
- Readiness and metrics endpoints stop answering once SIGTERM closes every listener, so orchestrators see a dead process during drain (cloudflare#505) - Add Service::keep_listening_on_terminate(&Server) behind the default-off keep_listening_on_terminate feature (pingora-core, forwarded by pingora-proxy and pingora); graceful upgrade still closes the listeners - Gate the method itself: a no-op when the feature is off would compile and still refuse readiness probes on SIGTERM - Document the SIGTERM/SIGQUIT behavior and add a proxy example with a draining readiness endpoint - Add unit and real-server tests, plus a CI step that lints, tests and builds the example with the feature enabled
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.
Addresses #505
Summary
Service::keep_listening_on_terminate(&Server)behind a default-offkeep_listening_on_terminateCargo feature, exposed bypingora-core,pingora-proxy, andpingoraMotivation
When SIGTERM starts graceful shutdown, listening services stop accepting new connections. Readiness probes and metrics scrapes on new connections are then refused while the process drains, preventing applications from reporting their drain state to those clients.
This opt-in keeps dedicated readiness and metrics services reachable until runtime shutdown, so the application chooses how they respond: keep returning 200, or report draining with a status such as 404 or 5xx. The example tracks draining with a background service's
ShutdownWatchand returns 503 while draining.Readiness and metrics example · API rustdoc and lifecycle caveats
Design
set_connection_filter(), which compiles as a no-op without its feature, this method is unavailable when the feature is disabled, so the requested shutdown behavior cannot silently disappear.&Server: the service obtains its execution-phase subscription directly from the server, so callers do not need to supply a receiver or arrange its subscription timing. BecauseServer::run(self)consumes the server, the method can't be called once it runs.ServerApp::cleanupis not called for these services, and an HTTP proxy'sSession::is_process_shutting_down()remainsfalse; applications use a separate shutdown notification to report draining. Calling cleanup while they still accept requests could dismantle resources they need.Cost
Option<Arc<_>>per service, cloned into each endpoint task, plus one check at shutdown; no per-connection or per-request work.Tests
ConnectionRefused.Feature-enabled CI step