From 6db98d6f0f211596f0c070b665b53b1f6ed1e9a4 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko <91597950+oksana-grishchenko@users.noreply.github.com> Date: Wed, 12 Feb 2025 22:44:44 +0200 Subject: [PATCH 1/2] EVEREST-1628 Do not use db.spec.backup.enabled (#656) Co-authored-by: Mayank Shah --- api/v1alpha1/databasecluster_types.go | 1 + .../manifests/everest-operator.clusterserviceversion.yaml | 2 +- bundle/manifests/everest.percona.com_databaseclusters.yaml | 4 +++- config/crd/bases/everest.percona.com_databaseclusters.yaml | 4 +++- deploy/bundle.yaml | 4 +++- internal/controller/databasecluster_controller.go | 2 +- internal/controller/providers/pg/applier.go | 7 ++----- internal/controller/providers/psmdb/applier.go | 4 ++-- internal/controller/providers/pxc/applier.go | 4 ++-- 9 files changed, 18 insertions(+), 14 deletions(-) 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..bbb254d1 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-06T11:37:23Z" 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..05447dc7 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 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..6312e16f 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 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..fc83dfb0 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 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 26fcc45f..217e75f7 100644 --- a/internal/controller/providers/pg/applier.go +++ b/internal/controller/providers/pg/applier.go @@ -950,11 +950,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 616a4d0a..7f5d142f 100644 --- a/internal/controller/providers/psmdb/applier.go +++ b/internal/controller/providers/psmdb/applier.go @@ -654,9 +654,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 } From cd8c6a78ee1c684c49c28904ebeaa0d2d063be78 Mon Sep 17 00:00:00 2001 From: Oksana Grishchenko Date: Fri, 14 Feb 2025 17:06:11 +0200 Subject: [PATCH 2/2] generated files --- bundle/manifests/everest-operator.clusterserviceversion.yaml | 2 +- bundle/manifests/everest.percona.com_databaseclusters.yaml | 2 +- config/crd/bases/everest.percona.com_databaseclusters.yaml | 2 +- deploy/bundle.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bundle/manifests/everest-operator.clusterserviceversion.yaml b/bundle/manifests/everest-operator.clusterserviceversion.yaml index bbb254d1..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-02-06T11:37:23Z" + 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 05447dc7..fa4725d6 100644 --- a/bundle/manifests/everest.percona.com_databaseclusters.yaml +++ b/bundle/manifests/everest.percona.com_databaseclusters.yaml @@ -71,7 +71,7 @@ spec: enabled: description: |- Enabled is a flag to enable backups - Deprecated. Please db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. + 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 6312e16f..a34abe80 100644 --- a/config/crd/bases/everest.percona.com_databaseclusters.yaml +++ b/config/crd/bases/everest.percona.com_databaseclusters.yaml @@ -71,7 +71,7 @@ spec: enabled: description: |- Enabled is a flag to enable backups - Deprecated. Please db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. + 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 fc83dfb0..4b21d1be 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -423,7 +423,7 @@ spec: enabled: description: |- Enabled is a flag to enable backups - Deprecated. Please db.spec.backup.schedules[].enabled to control each schedule separately and db.spec.backup.pitr.enabled to control PITR. + 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