diff --git a/api/v1alpha1/databasecluster_types.go b/api/v1alpha1/databasecluster_types.go index 7ea3e2bf..b864a820 100644 --- a/api/v1alpha1/databasecluster_types.go +++ b/api/v1alpha1/databasecluster_types.go @@ -284,6 +284,7 @@ type BackupSchedule struct { // Backup is the backup configuration. type Backup struct { // Enabled is a flag to enable backups + // Deprecated. Please use db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. Enabled bool `json:"enabled"` // Schedules is a list of backup schedules Schedules []BackupSchedule `json:"schedules,omitempty"` diff --git a/bundle/manifests/everest-operator.clusterserviceversion.yaml b/bundle/manifests/everest-operator.clusterserviceversion.yaml index b189eab8..90a7e712 100644 --- a/bundle/manifests/everest-operator.clusterserviceversion.yaml +++ b/bundle/manifests/everest-operator.clusterserviceversion.yaml @@ -78,7 +78,7 @@ metadata: } ] capabilities: Basic Install - createdAt: "2025-01-21T11:40:01Z" + createdAt: "2025-02-14T15:05:36Z" operators.operatorframework.io/builder: operator-sdk-v1.38.0 operators.operatorframework.io/project_layout: go.kubebuilder.io/v4 name: everest-operator.v0.0.0 diff --git a/bundle/manifests/everest.percona.com_databaseclusters.yaml b/bundle/manifests/everest.percona.com_databaseclusters.yaml index 9a32724b..fa4725d6 100644 --- a/bundle/manifests/everest.percona.com_databaseclusters.yaml +++ b/bundle/manifests/everest.percona.com_databaseclusters.yaml @@ -69,7 +69,9 @@ spec: description: Backup is the backup specification properties: enabled: - description: Enabled is a flag to enable backups + description: |- + Enabled is a flag to enable backups + Deprecated. Please use db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. type: boolean pitr: description: PITR is the configuration of the point in time recovery diff --git a/config/crd/bases/everest.percona.com_databaseclusters.yaml b/config/crd/bases/everest.percona.com_databaseclusters.yaml index 86e79960..a34abe80 100644 --- a/config/crd/bases/everest.percona.com_databaseclusters.yaml +++ b/config/crd/bases/everest.percona.com_databaseclusters.yaml @@ -69,7 +69,9 @@ spec: description: Backup is the backup specification properties: enabled: - description: Enabled is a flag to enable backups + description: |- + Enabled is a flag to enable backups + Deprecated. Please use db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. type: boolean pitr: description: PITR is the configuration of the point in time recovery diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index f82c76e4..4b21d1be 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -421,7 +421,9 @@ spec: description: Backup is the backup specification properties: enabled: - description: Enabled is a flag to enable backups + description: |- + Enabled is a flag to enable backups + Deprecated. Please use db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. type: boolean pitr: description: PITR is the configuration of the point in time recovery diff --git a/internal/controller/databasecluster_controller.go b/internal/controller/databasecluster_controller.go index 66a5e4d7..03bb1e1b 100644 --- a/internal/controller/databasecluster_controller.go +++ b/internal/controller/databasecluster_controller.go @@ -472,7 +472,7 @@ func (r *DatabaseClusterReconciler) initIndexers(ctx context.Context, mgr ctrl.M func(o client.Object) []string { var res []string database, ok := o.(*everestv1alpha1.DatabaseCluster) - if !ok || !database.Spec.Backup.Enabled { + if !ok { return res } for _, storage := range database.Spec.Backup.Schedules { diff --git a/internal/controller/providers/pg/applier.go b/internal/controller/providers/pg/applier.go index 4e246fdf..9937efc3 100644 --- a/internal/controller/providers/pg/applier.go +++ b/internal/controller/providers/pg/applier.go @@ -951,11 +951,8 @@ func (p *applier) reconcilePGBackupsSpec() (pgv2.Backups, error) { return pgv2.Backups{}, err } - // Only use the backup schedules if schedules are enabled in the DBC spec - backupSchedules := []everestv1alpha1.BackupSchedule{} - if database.Spec.Backup.Enabled { - backupSchedules = database.Spec.Backup.Schedules - } + backupSchedules := database.Spec.Backup.Schedules + // Add backup storages used by backup schedules to the list if err := p.addBackupStoragesBySchedules(backupSchedules, backupStorages, backupStoragesSecrets); err != nil { return pgv2.Backups{}, err diff --git a/internal/controller/providers/psmdb/applier.go b/internal/controller/providers/psmdb/applier.go index 6ea93d81..fbee25e1 100644 --- a/internal/controller/providers/psmdb/applier.go +++ b/internal/controller/providers/psmdb/applier.go @@ -661,9 +661,9 @@ func (p *applier) genPSMDBBackupSpec() (psmdbv1.BackupSpec, error) { return emptySpec, err } - // If scheduled backups are disabled, just return the storages used in + // If there are no schedules, just return the storages used in // DatabaseClusterBackup objects - if !database.Spec.Backup.Enabled { + if len(database.Spec.Backup.Schedules) == 0 { if len(storages) > 1 { return emptySpec, common.ErrPSMDBOneStorageRestriction } diff --git a/internal/controller/providers/pxc/applier.go b/internal/controller/providers/pxc/applier.go index 99d66d02..2e247d8a 100644 --- a/internal/controller/providers/pxc/applier.go +++ b/internal/controller/providers/pxc/applier.go @@ -592,8 +592,8 @@ func (p *applier) genPXCBackupSpec() (*pxcv1.PXCScheduledBackup, error) { } } - // If scheduled backups are disabled, just return the storages used in DatabaseClusterBackup objects - if !database.Spec.Backup.Enabled { + // If there are no schedules, just return the storages used in DatabaseClusterBackup objects + if len(database.Spec.Backup.Schedules) == 0 { pxcBackupSpec.Storages = storages return pxcBackupSpec, nil }