Documentation
¶
Overview ¶
Package drain implements the drain state machine for graceful pod removal. It handles the lifecycle of a pod being drained: from the initial drain request through standby removal, topo unregistration, and final readiness for deletion.
Index ¶
- Constants
- func ExecuteDrainStateMachine(ctx context.Context, k8sClient client.Client, ...) (bool, error)
- func IsPrimaryDraining(ctx context.Context, k8sClient client.Client, shard *multigresv1alpha1.Shard, ...) bool
- func IsPrimaryNotReady(ctx context.Context, k8sClient client.Client, shard *multigresv1alpha1.Shard, ...) bool
- func IsPrimaryTerminatingOrMissing(ctx context.Context, k8sClient client.Client, shard *multigresv1alpha1.Shard, ...) bool
- func UpdateDrainState(ctx context.Context, k8sClient client.Client, pod *corev1.Pod, newState string) (bool, error)
Constants ¶
const ( // DrainTimeout is the maximum time to wait for a failover or drain operation // before giving up and reporting an error. DrainTimeout = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
func ExecuteDrainStateMachine ¶
func ExecuteDrainStateMachine( ctx context.Context, k8sClient client.Client, rpcClient rpcclient.MultiPoolerClient, recorder record.EventRecorder, store topoclient.Store, shard *multigresv1alpha1.Shard, pod *corev1.Pod, ) (bool, error)
ExecuteDrainStateMachine handles the graceful scale down and etcd unregistration for a pod. Returns true if reconciliation should be requeued.
func IsPrimaryDraining ¶
func IsPrimaryDraining( ctx context.Context, k8sClient client.Client, shard *multigresv1alpha1.Shard, primary *clustermetadatapb.MultiPooler, ) bool
IsPrimaryDraining checks if the primary pooler's corresponding Kubernetes pod has drain annotations, indicating it is mid-drain and should not receive RPCs.
func IsPrimaryNotReady ¶
func IsPrimaryNotReady( ctx context.Context, k8sClient client.Client, shard *multigresv1alpha1.Shard, primary *clustermetadatapb.MultiPooler, ) bool
IsPrimaryNotReady checks if the primary pooler's corresponding Kubernetes pod has containers that are not passing readiness probes. This prevents sending RPCs to a pod whose multipooler cannot reach its local postgres.
func IsPrimaryTerminatingOrMissing ¶
func IsPrimaryTerminatingOrMissing( ctx context.Context, k8sClient client.Client, shard *multigresv1alpha1.Shard, primary *clustermetadatapb.MultiPooler, ) bool
IsPrimaryTerminatingOrMissing checks if the primary pooler's corresponding Kubernetes pod is unavailable for receiving RPCs because it is either missing or terminating.
Types ¶
This section is empty.