Documentation
¶
Overview ¶
Package rollout contains the rollout manager, allowing CloudNativePG to spread Pod rollouts depending on the passed configuration.
The manager uses a single global slot to enforce that only one Pod rollout proceeds at a time across all clusters managed by the operator. When Manager.CoordinateRollout is called and the rollout is allowed, the manager records the cluster, instance, and current timestamp. Subsequent calls are denied until the configured delay has elapsed: [Manager.clusterRolloutDelay] when the caller is a different cluster, or [Manager.instanceRolloutDelay] when it is the same cluster.
Because the slot is global, callers that will not actually perform a rollout must avoid calling Manager.CoordinateRollout. For example, a cluster whose primary update strategy is "supervised" waits indefinitely for a user-initiated switchover; if it claimed the slot, it would block every other cluster from rolling out until the delay expires, and would re-claim it on every reconciliation loop, effectively starving other clusters.
The delays are configured via the CLUSTERS_ROLLOUT_DELAY and INSTANCES_ROLLOUT_DELAY operator environment variables (both default to 0, meaning no delay).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the rollout manager. It is safe to use concurrently.
A single Manager instance is shared across all cluster reconciliations. It tracks the most recent rollout in a single slot (lastCluster, lastInstance, lastUpdate). This means only one rollout can be in progress at a time: any call to Manager.CoordinateRollout that arrives before the applicable delay has elapsed will be denied.
func (*Manager) CoordinateRollout ¶
CoordinateRollout checks whether a Pod rollout is allowed and, when allowed, claims the global slot by recording the cluster, instance, and current time.
Callers must only invoke this method when they intend to actually perform a rollout. Calling it without following through (e.g. for a supervised primary that only waits for user action) would occupy the slot and block other clusters from rolling out.
type Result ¶
type Result struct {
// This is true when the Pod can be rolled out immediately
RolloutAllowed bool
// This is set with the amount of time the operator need
// to wait to rollout that Pod
TimeToWait time.Duration
}
Result is the output of the rollout manager, telling the operator how much time we need to wait to rollout a Pod