Skip to main content

DEFAULT_TASK_GRACE

Constant DEFAULT_TASK_GRACE 

Source
pub const DEFAULT_TASK_GRACE: Duration;
Expand description

How long in-flight tasks get, once cancelled at shutdown, to act on their cancellation before the connection drain starts.

Ten seconds is enough for an executor to send CancelTask to the agents it delegated to — one round trip each, in parallel or not — and for its terminal event to be persisted and flushed to open streams.

With DEFAULT_COMPLETION_GRACE and DEFAULT_DRAIN_TIMEOUT the three phases are bounded by 30 seconds together, which is exactly a Kubernetes terminationGracePeriodSeconds default, so set that higher if the bound can be reached. It rarely is: each phase ends as soon as its work does, and by the time the drain starts a stream whose task has ended is a connection that closes.