Repository navigation
docs(fault-tolerance): clarify migration after shutdown grace expires #14872
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,8 @@ subtitle: Let workers finish in-flight requests and release resources cleanly wh | |
|
|
||
| When Kubernetes terminates a pod (rollout, scale-down, node drain), Dynamo workers stop accepting new requests, keep serving in-flight ones through a grace period, then release engine and connection resources before exiting. This is **on by default** — every component handles `SIGTERM`/`SIGINT` and drains automatically. The steps below tune *how long* it waits and make sure interrupted requests are recovered. | ||
|
|
||
| Expiry of `DYN_GRACEFUL_SHUTDOWN_GRACE_PERIOD_SECS` initiates cancellation of unfinished requests. The Frontend can migrate these requests to a healthy worker when migration is enabled and policy permits it; otherwise the client receives an error. Exhausted retries or an exceeded sequence-length cap can prevent recovery. | ||
|
kthui marked this conversation as resolved.
Resolved
kthui marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a little too precise about the timing. Grace-period expiry does not necessarily immediately initiate cancellation:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, the original wording was too precise about grace expiry. Updated it to: “Once shutdown proceeds past the grace period and any backend-specific draining, workers initiate cancellation of unfinished requests.” This accounts for the extra draining time after grace, as you suggested. |
||
|
|
||
| The knobs are three timeouts plus enabling migration. The default flow: endpoints unregister from discovery immediately, workers serve for a short grace period, then endpoints drain (bounded by a timeout) before resources are cleaned up. | ||
|
|
||
| > **How it works:** the signal handlers, the `graceful_shutdown()` sequence, per-backend `cleanup()` code, and error-initiated shutdown are documented in [Graceful Shutdown Architecture](../../developer-guide/knowledge-base/concepts/fault-tolerance/graceful-shutdown-architecture.md). | ||
|
|
@@ -54,7 +56,7 @@ The defaults are sound for most deployments. Raise the relevant timeout only for | |
|
|
||
| <Step title="Enable migration so drained requests retry"> | ||
|
|
||
| Draining lets *current* requests finish, but a request interrupted by an unexpected worker loss still needs somewhere to go. Enable [request migration](request-migration.md) on the Frontend so disconnected streams are retried on healthy workers. Set `DYN_MIGRATION_LIMIT` in the Frontend `env:` (or `--migration-limit` in its `args:`): | ||
| Draining lets *current* requests finish during the grace period set by `DYN_GRACEFUL_SHUTDOWN_GRACE_PERIOD_SECS`, but a request interrupted after the shutdown grace period expires or by an unexpected worker loss still needs somewhere to go. Enable [request migration](request-migration.md) on the Frontend for rolling upgrades and scale-downs as well, so eligible interrupted requests are retried on healthy workers. Set `DYN_MIGRATION_LIMIT` in the Frontend `env:` (or `--migration-limit` in its `args:`): | ||
|
|
||
| ```yaml | ||
| - name: Frontend | ||
|
|
@@ -90,7 +92,7 @@ During Frontend shutdown, `/health` returns 503 so readiness routing stops, whil | |
| finish or `DYN_HTTP_GRACEFUL_SHUTDOWN_TIMEOUT_SECS` expires. | ||
|
|
||
| During worker shutdown, endpoints unregister and stop receiving new work while admitted requests | ||
| complete. If a pod receives `SIGKILL` before draining finishes, increase | ||
| have time to complete. If a pod receives `SIGKILL` before draining finishes, increase | ||
| `terminationGracePeriodSeconds` (step 1) or lower the relevant internal timeout (step 2). | ||
|
|
||
| </Step> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The shutdown sequence here is missing the
shutdown_eventstep that is directly relevant to the migration behavior this PR documents. After the grace period,graceful_shutdown_with_discovery()may first rundrain_callback/pre_shutdown_callback, then setsshutdown_event, and only later callsruntime.shutdown(). Backend handlers useshutdown_eventto abort unfinished generation withEngineShutdown, which the migrator treats as migratable. Could we update this sequence to reflect that ordering?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this. Updated the sequence in d4a074e74d to include the optional drain/pre-shutdown callbacks and show
shutdown_eventbeing set beforeruntime.shutdown().