controller

package
v1.26.0 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: Apache-2.0 Imports: 68 Imported by: 0

Documentation

Overview

Package controller contains the controller of the CRD

Package controller contains the controller of the CRD

Package controller contains the controller of the CRD

Index

Constants

View Source
const (

	// ImmediateBackupLabelName label is applied to backups to tell if a backup
	// is immediate or not
	ImmediateBackupLabelName = utils.ImmediateBackupLabelName

	// ParentScheduledBackupLabelName label is applied to backups to easily tell the scheduled backup
	// it was created from.
	ParentScheduledBackupLabelName = utils.ParentScheduledBackupLabelName
)

Variables

View Source
var ErrNextLoop = utils.ErrNextLoop

ErrNextLoop see utils.ErrNextLoop

View Source
var ErrWaitingOnFailOverDelay = fmt.Errorf("current primary isn't healthy, waiting for the delay before triggering a failover") //nolint: lll

ErrWaitingOnFailOverDelay is raised when the primary server can't be elected because the .spec.failoverDelay hasn't elapsed yet

View Source
var ErrWalReceiversRunning = fmt.Errorf("wal receivers are still running")

ErrWalReceiversRunning is raised when a new primary server can't be elected because there is a WAL receiver running in our Pod list

Functions

func GetManagedInstances

func GetManagedInstances(ctx context.Context, cluster *apiv1.Cluster, r client.Client) (corev1.PodList, error)

GetManagedInstances gets all the instances associated with the given Cluster

func GetPodsNotOnPrimaryNode

func GetPodsNotOnPrimaryNode(
	status postgres.PostgresqlStatusList,
	primaryPod *postgres.PostgresqlStatus,
) postgres.PostgresqlStatusList

GetPodsNotOnPrimaryNode filters out only pods that are not on the same node as the primary one

func IsOwnedByCluster

func IsOwnedByCluster(obj client.Object) (string, bool)

IsOwnedByCluster checks that an object is owned by a Cluster and returns the owner name

func ReconcileScheduledBackup

func ReconcileScheduledBackup(
	ctx context.Context,
	event record.EventRecorder,
	cli client.Client,
	scheduledBackup *apiv1.ScheduledBackup,
) (ctrl.Result, error)

ReconcileScheduledBackup is the main reconciliation logic for a scheduled backup

Types

type BackupReconciler

type BackupReconciler struct {
	client.Client
	DiscoveryClient discovery.DiscoveryInterface

	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
	Plugins  repository.Interface
	// contains filtered or unexported fields
}

BackupReconciler reconciles a Backup object

func NewBackupReconciler

func NewBackupReconciler(
	mgr manager.Manager,
	discoveryClient *discovery.DiscoveryClient,
	plugins repository.Interface,
) *BackupReconciler

NewBackupReconciler properly initializes the BackupReconciler

func (*BackupReconciler) Reconcile

func (r *BackupReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is the main reconciliation loop nolint: gocognit,gocyclo

func (*BackupReconciler) SetupWithManager

func (r *BackupReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager) error

SetupWithManager sets up this controller given a controller manager

type ClusterReconciler

type ClusterReconciler struct {
	client.Client

	DiscoveryClient discovery.DiscoveryInterface
	Scheme          *runtime.Scheme
	Recorder        record.EventRecorder
	InstanceClient  remote.InstanceClient
	Plugins         repository.Interface
	// contains filtered or unexported fields
}

ClusterReconciler reconciles a Cluster objects

func NewClusterReconciler

func NewClusterReconciler(
	mgr manager.Manager,
	discoveryClient *discovery.DiscoveryClient,
	plugins repository.Interface,
	drainTaints []string,
) *ClusterReconciler

NewClusterReconciler creates a new ClusterReconciler initializing it

func (*ClusterReconciler) Reconcile

func (r *ClusterReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is the operator reconcile loop

func (*ClusterReconciler) RegisterPhase

func (r *ClusterReconciler) RegisterPhase(ctx context.Context,
	cluster *apiv1.Cluster,
	phase string,
	reason string,
) error

RegisterPhase update phase in the status cluster with the proper reason

func (*ClusterReconciler) SetupWithManager

func (r *ClusterReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Manager, maxConcurrentReconciles int) error

SetupWithManager creates a ClusterReconciler

type PluginReconciler added in v1.24.0

type PluginReconciler struct {
	client.Client

	Scheme  *runtime.Scheme
	Plugins repository.Interface

	OperatorNamespace string
}

PluginReconciler reconciles CNPG-i plugins

func NewPluginReconciler added in v1.24.0

func NewPluginReconciler(
	mgr manager.Manager,
	operatorNamespace string,
	plugins repository.Interface,
) *PluginReconciler

NewPluginReconciler creates a new PluginReconciler initializing it

func (*PluginReconciler) Reconcile added in v1.24.0

func (r *PluginReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile is the reconciler loop

func (*PluginReconciler) SetupWithManager added in v1.24.0

func (r *PluginReconciler) SetupWithManager(
	mgr ctrl.Manager,
	maxConcurrentReconciles int,
) error

SetupWithManager adds this PluginReconciler to the passed controller manager

type PoolerReconciler

type PoolerReconciler struct {
	client.Client
	DiscoveryClient discovery.DiscoveryInterface
	Scheme          *runtime.Scheme
	Recorder        record.EventRecorder
}

PoolerReconciler reconciles a Pooler object

func (*PoolerReconciler) Reconcile

func (r *PoolerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile implements the main reconciliation loop for pooler objects

func (*PoolerReconciler) SetupWithManager

func (r *PoolerReconciler) SetupWithManager(mgr ctrl.Manager, maxConcurrentReconciles int) error

SetupWithManager setup this controller inside the controller manager

type ScheduledBackupReconciler

type ScheduledBackupReconciler struct {
	client.Client
	Scheme   *runtime.Scheme
	Recorder record.EventRecorder
}

ScheduledBackupReconciler reconciles a ScheduledBackup object

func (*ScheduledBackupReconciler) GetChildBackups

func (r *ScheduledBackupReconciler) GetChildBackups(
	ctx context.Context,
	scheduledBackup apiv1.ScheduledBackup,
) ([]apiv1.Backup, error)

GetChildBackups gets all the backups scheduled by a certain scheduler

func (*ScheduledBackupReconciler) Reconcile

Reconcile is the main reconciler logic

func (*ScheduledBackupReconciler) SetupWithManager

func (r *ScheduledBackupReconciler) SetupWithManager(
	ctx context.Context,
	mgr ctrl.Manager,
	maxConcurrentReconciles int,
) error

SetupWithManager install this controller in the controller manager

Directories

Path Synopsis
Package rollout contains the rollout manager, allowing CloudNative-PG to spread Pod rollouts depending on the passed configuration
Package rollout contains the rollout manager, allowing CloudNative-PG to spread Pod rollouts depending on the passed configuration

Jump to

Keyboard shortcuts

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