controller

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRoleBindingForBackupConfig

func BuildRoleBindingForBackupConfig(
	cluster *cnpgv1.Cluster,
) *rbacv1.RoleBinding

BuildRoleBinding builds the role binding object for this cluster

func BuildRoleForBackupConfigs

func BuildRoleForBackupConfigs(
	role *rbacv1.Role,
	cluster *cnpgv1.Cluster,
	backupConfigs []v1beta1.BackupConfig,
)

BuildRole builds the Role object for this cluster It collects all BackupConfig objects used by cluster and grants read/watch permissions on them only It also finds all secrets referenced by these BackupConfig and grants read permission on them

func GetRoleNameForBackupConfig added in v0.2.0

func GetRoleNameForBackupConfig(clusterName string) string

GetRBACName returns the name of the RBAC entities for the wal-g backup configs

Types

type BackupConfigReconciler

type BackupConfigReconciler struct {
	client.Client
	Scheme                   *runtime.Scheme
	BackupDeletionController *BackupDeletionController
}

BackupConfigReconciler reconciles a BackupConfig object

func (*BackupConfigReconciler) Reconcile

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

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.20.4/pkg/reconcile

func (*BackupConfigReconciler) SetupWithManager

func (r *BackupConfigReconciler) SetupWithManager(mgr ctrl.Manager, backupDeletionController *BackupDeletionController) error

SetupWithManager sets up the controller with the Manager.

type BackupConfigStatusController added in v0.3.0

type BackupConfigStatusController struct {
	// contains filtered or unexported fields
}

BackupConfigStatusController periodically reconciles BackupConfigStatus fields for all BackupConfig resources. It uses a static goroutine pool with a single shared queue to limit concurrency and prevent overloading S3 storage.

Per-BackupConfig deduplication ensures that the same resource is not reconciled concurrently by multiple workers. Manual status updates can be enqueued via EnqueueStatusUpdate.

func NewBackupConfigStatusController added in v0.3.0

func NewBackupConfigStatusController(client client.Client, checkInterval time.Duration) *BackupConfigStatusController

NewBackupConfigStatusController creates a new BackupConfigStatusController

func (*BackupConfigStatusController) EnqueueStatusUpdate added in v0.3.0

func (c *BackupConfigStatusController) EnqueueStatusUpdate(key types.NamespacedName)

EnqueueStatusUpdate enqueues a status reconciliation for a specific BackupConfig. This can be called externally (e.g. after backup creation or BackupConfig changes) to trigger an immediate status update. Non-blocking: if the queue is full, the request is dropped (the periodic reconciliation will pick it up later).

func (*BackupConfigStatusController) NeedLeaderElection added in v0.3.0

func (c *BackupConfigStatusController) NeedLeaderElection() bool

NeedLeaderElection returns true if the Runnable needs to be run in the leader election mode. e.g. controllers need to be run in leader election mode, while webhook server doesn't.

func (*BackupConfigStatusController) Start added in v0.3.0

Start begins the status controller's periodic reconciliation loop and worker pool

type BackupDeletionController added in v0.2.0

type BackupDeletionController struct {
	client.Client
	// contains filtered or unexported fields
}

BackupDeletionController handles Backup and BackupConfig deletion requests and processes them sequentially per BackupConfig to prevent operator from overloading and wal-g collisions at deleting backups at the same storage

func NewBackupDeletionController added in v0.2.0

func NewBackupDeletionController(client client.Client) *BackupDeletionController

NewBackupDeletionController creates a new BackupDeletionController

func (*BackupDeletionController) EnqueueBackupConfigDeletion added in v0.2.2

func (b *BackupDeletionController) EnqueueBackupConfigDeletion(ctx context.Context, backupConfig *v1beta1.BackupConfig) error

EnqueueBackupConfigDeletion adds a BackupConfig to the deletion queue If the queue doesn't exist, it creates a new one and starts a goroutine to process it

func (*BackupDeletionController) EnqueueBackupDeletion added in v0.2.0

func (b *BackupDeletionController) EnqueueBackupDeletion(ctx context.Context, backup *cnpgv1.Backup) error

EnqueueBackupDeletion adds a Backup to the deletion queue for its BackupConfig If the queue doesn't exist, it creates a new one and starts a goroutine to process it

func (*BackupDeletionController) NeedLeaderElection added in v0.3.0

func (b *BackupDeletionController) NeedLeaderElection() bool

NeedLeaderElection returns true if the Runnable needs to be run in the leader election mode. e.g. controllers need to be run in leader election mode, while webhook server doesn't.

func (*BackupDeletionController) Start added in v0.2.0

Start begins the backup deletion controller's periodic check

type BackupReconciler added in v0.2.0

type BackupReconciler struct {
	client.Client
	Scheme             *runtime.Scheme
	DeletionController *BackupDeletionController
}

BackupReconciler reconciles a Backup object

func (*BackupReconciler) Reconcile added in v0.2.0

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

Reconcile handles Backup resource events

func (*BackupReconciler) SetupWithManager added in v0.2.0

func (r *BackupReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type ConfigMapReconciler added in v0.2.2

type ConfigMapReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

ConfigMapReconciler reconciles ConfigMap objects to protect them from accidental deletion when they are referenced by BackupConfig resources

func (*ConfigMapReconciler) Reconcile added in v0.2.2

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

Reconcile handles ConfigMap resource events

func (*ConfigMapReconciler) SetupWithManager added in v0.2.2

func (r *ConfigMapReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type DeletionRequest added in v0.2.2

type DeletionRequest struct {
	// Type of resource to delete
	Type ResourceType
	// NamespacedName of the resource
	Key types.NamespacedName
}

DeletionRequest represents a request to delete a resource

type ResourceType added in v0.2.2

type ResourceType string

ResourceType defines the type of resource being deleted

const (
	// ResourceTypeBackup represents a Backup resource
	ResourceTypeBackup ResourceType = "Backup"
	// ResourceTypeBackupConfig represents a BackupConfig resource
	ResourceTypeBackupConfig ResourceType = "BackupConfig"

	// Timeout for resource cleanup, if exceeded - deletion process will be aborted and retried
	// Needed to prevent stuck on deletion when incorrect BackupConfig / etc.
	DeletionRequestTimeout time.Duration = 5 * time.Minute
)

type RetentionController added in v0.2.0

type RetentionController struct {
	// contains filtered or unexported fields
}

RetentionController periodically checks all BackupConfig resources and applies retention policies to delete old backups

func NewRetentionController added in v0.2.0

func NewRetentionController(client client.Client, checkInterval time.Duration) *RetentionController

NewRetentionController creates a new RetentionController

func (*RetentionController) Start added in v0.2.0

func (r *RetentionController) Start(ctx context.Context) error

Start begins the retention controller's periodic check

type SecretReconciler added in v0.2.2

type SecretReconciler struct {
	client.Client
	Scheme *runtime.Scheme
}

SecretReconciler reconciles Secret objects to protect them from accidental deletion when they are referenced by BackupConfig resources

func (*SecretReconciler) Reconcile added in v0.2.2

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

Reconcile handles Secret resource events

func (*SecretReconciler) SetupWithManager added in v0.2.2

func (r *SecretReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

Jump to

Keyboard shortcuts

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