drain

package
v0.0.0-...-84176c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package drain holds the timing of the two-phase endpoint drain (#152) that more than one component must agree on.

Phase 1 marks a terminating pod's endpoint DRAINING the moment its deletion is requested (no new selections). Phase 2 marks it UNHEALTHY a little before the application receives SIGTERM, so every source's close_connections_on_host_health_failure closes its by-then-idle pools while the app still serves. The node agent schedules phase 2 for the pods on its node; the registrar's kubernetes backend derives the same moment from the Pod so that every registrar replica lists the pod UNHEALTHY at it, not only the replica the agent's mark reached (aether#1144). Both read PoolCloseDelay, so they cannot drift.

Index

Constants

View Source
const PoolCloseFloor = 2 * time.Second

PoolCloseFloor is the phase-2 floor: long enough for phase 1's DRAINING to propagate (~1 s broadcast + EDS apply) and for fast in-flight requests to complete, short enough to land inside the minimum preStop window (workload-requirements: preStop sleep >= 3 s) so pools close before the app exits. Workloads with a longer sleep preStop get a proportionally longer drain window (PoolCloseDelay).

Variables

This section is empty.

Functions

func PoolCloseAt

func PoolCloseAt(pod *corev1.Pod) (time.Time, bool)

PoolCloseAt is when phase 2 is due for a pod whose deletion was requested, derived from the Pod alone: the request time plus PoolCloseDelay with the production floor. ok is false when the pod carries no deletion request.

The API server sets deletionTimestamp to request time + grace and records the grace in deletionGracePeriodSeconds, so the request time is their difference. deletionTimestamp is serialized at one-second resolution (truncated), so the result is up to 1 s EARLIER than the node agent's own timer, which starts when its informer sees the request. Earlier is the safe side of the intent: the pools still close before SIGTERM, never after it.

func PoolCloseDelay

func PoolCloseDelay(pod *corev1.Pod, floor time.Duration) time.Duration

PoolCloseDelay sizes phase 2 to the workload, from the moment deletion was requested: as generous an in-flight window as the pod's own shutdown sequence allows. The bound is NOT the termination grace period (default 30 s) -- it is the moment the app receives SIGTERM (when its preStop hook finishes), because the pool close must land while the app is still serving to pre-empt the exit-GOAWAY race. A sleep preStop is machine-readable, so the drain window scales with it: close 1 s before SIGTERM, capped 2 s short of the deletion grace (the kubelet's hard kill). Exec preStop hooks and hookless pods are opaque, so they keep the floor.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL