drain

package
v0.10.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

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

View Source
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.

func UpdateDrainState

func UpdateDrainState(
	ctx context.Context,
	k8sClient client.Client,
	pod *corev1.Pod,
	newState string,
) (bool, error)

UpdateDrainState patches a pod's drain state annotation.

Types

This section is empty.

Jump to

Keyboard shortcuts

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