From 6ba934b3ca5d459aa7e9d6236672d5e612ca8321 Mon Sep 17 00:00:00 2001 From: Viacheslav Sarzhan Date: Fri, 17 Jul 2026 20:13:11 +0300 Subject: [PATCH 1/4] K8SPG-1011 drop crunchy- prefix from missing image error and default backups.enabled --- .../pgv2.percona.com_perconapgclusters.yaml | 3 +++ .../bases/pgv2.percona.com_perconapgclusters.yaml | 3 +++ deploy/cr.yaml | 1 + deploy/crd.yaml | 3 +++ internal/config/config.go | 12 ++++++------ .../pgv2.percona.com/v2/perconapgcluster_types.go | 3 +++ 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml b/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml index 226cb7b95..fe05e4b38 100644 --- a/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml +++ b/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml @@ -121,6 +121,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: + default: true + description: Enabled controls whether backups are enabled for + the cluster. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml b/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml index 8bf33616d..6a9fd5aa7 100644 --- a/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml +++ b/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml @@ -819,6 +819,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: + default: true + description: Enabled controls whether backups are enabled for + the cluster. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/deploy/cr.yaml b/deploy/cr.yaml index 8a17bce26..07f69f42e 100644 --- a/deploy/cr.yaml +++ b/deploy/cr.yaml @@ -487,6 +487,7 @@ spec: # pool_mode: transaction backups: +# enabled: true # trackLatestRestorableTime: true # volumeSnapshots: # mode: offline diff --git a/deploy/crd.yaml b/deploy/crd.yaml index bd9fce8c6..9f31f4a63 100644 --- a/deploy/crd.yaml +++ b/deploy/crd.yaml @@ -1116,6 +1116,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: + default: true + description: Enabled controls whether backups are enabled for + the cluster. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/internal/config/config.go b/internal/config/config.go index e62c0bf9f..fda998339 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -139,29 +139,29 @@ func VerifyImageValues(cluster *v1beta1.PostgresCluster) error { dataSourceRestore := cluster.Spec.DataSource != nil && cluster.Spec.DataSource.PostgresCluster != nil // K8SPG-710: Image check will fail without a backup section in PostgresCluster if (cluster.BackupSpecFound() && backupsEnabled || dataSourceRestore) && PGBackRestContainerImage(cluster) == "" { - images = append(images, "crunchy-pgbackrest") + images = append(images, "pgbackrest") } if PGAdminContainerImage(cluster) == "" && cluster.Spec.UserInterface != nil && cluster.Spec.UserInterface.PGAdmin != nil { - images = append(images, "crunchy-pgadmin4") + images = append(images, "pgadmin4") } if PGBouncerContainerImage(cluster) == "" && cluster.Spec.Proxy != nil && cluster.Spec.Proxy.PGBouncer != nil { - images = append(images, "crunchy-pgbouncer") + images = append(images, "pgbouncer") } if PGExporterContainerImage(cluster) == "" && cluster.Spec.Monitoring != nil && cluster.Spec.Monitoring.PGMonitor != nil && cluster.Spec.Monitoring.PGMonitor.Exporter != nil { - images = append(images, "crunchy-postgres-exporter") + images = append(images, "postgres-exporter") } if PostgresContainerImage(cluster) == "" { if cluster.Spec.PostGISVersion != "" { - images = append(images, "crunchy-postgres-gis") + images = append(images, "postgres-gis") } else { - images = append(images, "crunchy-postgres") + images = append(images, "postgres") } } diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index 130797dfa..b9726214c 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -642,6 +642,9 @@ type Patroni struct { // Backups struct. // +kubebuilder:validation:XValidation:rule="(has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos) && size(self.pgbackrest.repos) > 0)",message="At least one repository must be configured when backups are enabled" type Backups struct { + // Enabled controls whether backups are enabled for the cluster. + // +optional + // +kubebuilder:default=true Enabled *bool `json:"enabled,omitempty"` // pgBackRest archive configuration From 1d820e201c09b3721984d4d93a4da7c0af7faab6 Mon Sep 17 00:00:00 2001 From: Viacheslav Sarzhan Date: Fri, 17 Jul 2026 20:22:13 +0300 Subject: [PATCH 2/4] fix comments --- deploy/bundle.yaml | 3 +++ deploy/cw-bundle.yaml | 3 +++ internal/config/config_test.go | 38 +++++++++++++++++----------------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index 0eddf1619..1939e878e 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -1116,6 +1116,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: + default: true + description: Enabled controls whether backups are enabled for + the cluster. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/deploy/cw-bundle.yaml b/deploy/cw-bundle.yaml index 3492ff9ce..d0ee1bf83 100644 --- a/deploy/cw-bundle.yaml +++ b/deploy/cw-bundle.yaml @@ -1116,6 +1116,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: + default: true + description: Enabled controls whether backups are enabled for + the cluster. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 9ecc59c1c..f6cd42454 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -202,17 +202,17 @@ func TestPostgresContainerImage(t *testing.T) { } func TestVerifyImageValues(t *testing.T) { - t.Run("crunchy-postgres", func(t *testing.T) { + t.Run("postgres", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 t.Setenv("RELATED_IMAGE_POSTGRES_14", "") os.Unsetenv("RELATED_IMAGE_POSTGRES_14") err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-postgres") + assert.ErrorContains(t, err, "postgres") }) - t.Run("crunchy-postgres-gis", func(t *testing.T) { + t.Run("postgres-gis", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 cluster.Spec.PostGISVersion = "3.3" @@ -220,10 +220,10 @@ func TestVerifyImageValues(t *testing.T) { os.Unsetenv("RELATED_IMAGE_POSTGRES_14_GIS_3.3") err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-postgres-gis") + assert.ErrorContains(t, err, "postgres-gis") }) - t.Run("crunchy-pgbackrest-enabled", func(t *testing.T) { + t.Run("pgbackrest-enabled", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 enabled := true @@ -232,10 +232,10 @@ func TestVerifyImageValues(t *testing.T) { os.Unsetenv("RELATED_IMAGE_PGBACKREST") err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-pgbackrest") + assert.ErrorContains(t, err, "pgbackrest") }) - t.Run("crunchy-pgbackrest-disabled", func(t *testing.T) { + t.Run("pgbackrest-disabled", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 enabled := false @@ -244,10 +244,10 @@ func TestVerifyImageValues(t *testing.T) { os.Unsetenv("RELATED_IMAGE_PGBACKREST") err := VerifyImageValues(cluster) - assert.Assert(t, !strings.Contains(err.Error(), "crunchy-pgbackrest")) + assert.Assert(t, !strings.Contains(err.Error(), "pgbackrest")) }) - t.Run("crunchy-pgbouncer", func(t *testing.T) { + t.Run("pgbouncer", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 cluster.Spec.Proxy = &v1beta1.PostgresProxySpec{ @@ -257,10 +257,10 @@ func TestVerifyImageValues(t *testing.T) { os.Unsetenv("RELATED_IMAGE_PGBOUNCER") err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-pgbouncer") + assert.ErrorContains(t, err, "pgbouncer") }) - t.Run("crunchy-pgadmin4", func(t *testing.T) { + t.Run("pgadmin4", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 cluster.Spec.UserInterface = &v1beta1.UserInterfaceSpec{ @@ -270,10 +270,10 @@ func TestVerifyImageValues(t *testing.T) { os.Unsetenv("RELATED_IMAGE_PGADMIN") err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-pgadmin4") + assert.ErrorContains(t, err, "pgadmin4") }) - t.Run("crunchy-postgres-exporter", func(t *testing.T) { + t.Run("postgres-exporter", func(t *testing.T) { cluster := &v1beta1.PostgresCluster{} cluster.Spec.PostgresVersion = 14 cluster.Spec.Monitoring = &v1beta1.MonitoringSpec{ @@ -285,7 +285,7 @@ func TestVerifyImageValues(t *testing.T) { os.Unsetenv("RELATED_IMAGE_PGEXPORTER") err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-postgres-exporter") + assert.ErrorContains(t, err, "postgres-exporter") }) t.Run("multiple missing images", func(t *testing.T) { @@ -307,11 +307,11 @@ func TestVerifyImageValues(t *testing.T) { } err := VerifyImageValues(cluster) - assert.ErrorContains(t, err, "crunchy-postgres-gis") - assert.ErrorContains(t, err, "crunchy-pgbackrest") - assert.ErrorContains(t, err, "crunchy-pgbouncer") - assert.ErrorContains(t, err, "crunchy-pgadmin4") - assert.ErrorContains(t, err, "crunchy-postgres-exporter") + assert.ErrorContains(t, err, "postgres-gis") + assert.ErrorContains(t, err, "pgbackrest") + assert.ErrorContains(t, err, "pgbouncer") + assert.ErrorContains(t, err, "pgadmin4") + assert.ErrorContains(t, err, "postgres-exporter") }) t.Run("all images set", func(t *testing.T) { From 7f0832caa3ae0c67906bf0eab3e466e019bcb3ce Mon Sep 17 00:00:00 2001 From: Viacheslav Sarzhan Date: Sat, 18 Jul 2026 14:29:03 +0300 Subject: [PATCH 3/4] fix tests --- .../pgv2.percona.com_perconapgclusters.yaml | 6 ++-- .../pgv2.percona.com_perconapgclusters.yaml | 6 ++-- deploy/bundle.yaml | 6 ++-- deploy/crd.yaml | 6 ++-- deploy/cw-bundle.yaml | 6 ++-- .../v2/perconapgcluster_types.go | 6 +++- .../v2/perconapgcluster_types_test.go | 29 +++++++++++++++++++ 7 files changed, 49 insertions(+), 16 deletions(-) diff --git a/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml b/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml index fe05e4b38..d600b02bb 100644 --- a/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml +++ b/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml @@ -121,9 +121,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: - default: true - description: Enabled controls whether backups are enabled for - the cluster. + description: |- + Enabled controls whether backups are enabled for the cluster. + Defaulted to true by the operator for crVersion >= 3.1.0. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml b/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml index 6a9fd5aa7..2ff064e99 100644 --- a/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml +++ b/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml @@ -819,9 +819,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: - default: true - description: Enabled controls whether backups are enabled for - the cluster. + description: |- + Enabled controls whether backups are enabled for the cluster. + Defaulted to true by the operator for crVersion >= 3.1.0. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index 1939e878e..fff58aecb 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -1116,9 +1116,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: - default: true - description: Enabled controls whether backups are enabled for - the cluster. + description: |- + Enabled controls whether backups are enabled for the cluster. + Defaulted to true by the operator for crVersion >= 3.1.0. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/deploy/crd.yaml b/deploy/crd.yaml index 9f31f4a63..340b6668f 100644 --- a/deploy/crd.yaml +++ b/deploy/crd.yaml @@ -1116,9 +1116,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: - default: true - description: Enabled controls whether backups are enabled for - the cluster. + description: |- + Enabled controls whether backups are enabled for the cluster. + Defaulted to true by the operator for crVersion >= 3.1.0. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/deploy/cw-bundle.yaml b/deploy/cw-bundle.yaml index d0ee1bf83..eb89883bf 100644 --- a/deploy/cw-bundle.yaml +++ b/deploy/cw-bundle.yaml @@ -1116,9 +1116,9 @@ spec: description: PostgreSQL backup configuration properties: enabled: - default: true - description: Enabled controls whether backups are enabled for - the cluster. + description: |- + Enabled controls whether backups are enabled for the cluster. + Defaulted to true by the operator for crVersion >= 3.1.0. type: boolean pgbackrest: description: pgBackRest archive configuration diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index b9726214c..41f32bb54 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -314,6 +314,10 @@ func (cr *PerconaPGCluster) Default() { cr.Spec.AutoCreateUserSchema = new(true) } + if cr.CompareVersion("3.1.0") >= 0 && cr.Spec.Backups.Enabled == nil { + cr.Spec.Backups.Enabled = new(true) + } + if cr.CompareVersion("2.9.0") < 0 && cr.Spec.Config == nil { cr.Spec.Config = &crunchyv1beta1.PostgresConfigSpec{} } @@ -643,8 +647,8 @@ type Patroni struct { // +kubebuilder:validation:XValidation:rule="(has(self.enabled) && self.enabled == false) || (has(self.pgbackrest.repos) && size(self.pgbackrest.repos) > 0)",message="At least one repository must be configured when backups are enabled" type Backups struct { // Enabled controls whether backups are enabled for the cluster. + // Defaulted to true by the operator for crVersion >= 3.1.0. // +optional - // +kubebuilder:default=true Enabled *bool `json:"enabled,omitempty"` // pgBackRest archive configuration diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go index 32bc035e5..33af960cf 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go @@ -24,6 +24,35 @@ func TestPerconaPGCluster_Default(t *testing.T) { new(PerconaPGCluster).Default() } +func TestPerconaPGCluster_DefaultBackupsEnabled(t *testing.T) { + t.Run("nil is defaulted to true for CRVersion >= 3.1.0", func(t *testing.T) { + cr := new(PerconaPGCluster) + cr.Spec.CRVersion = "3.1.0" + cr.Default() + + require.NotNil(t, cr.Spec.Backups.Enabled) + assert.True(t, *cr.Spec.Backups.Enabled) + }) + + t.Run("nil is left untouched for CRVersion < 3.1.0", func(t *testing.T) { + cr := new(PerconaPGCluster) + cr.Spec.CRVersion = "3.0.0" + cr.Default() + + assert.Nil(t, cr.Spec.Backups.Enabled) + }) + + t.Run("explicit false is preserved for CRVersion >= 3.1.0", func(t *testing.T) { + cr := new(PerconaPGCluster) + cr.Spec.CRVersion = "3.1.0" + cr.Spec.Backups.Enabled = new(false) + cr.Default() + + require.NotNil(t, cr.Spec.Backups.Enabled) + assert.False(t, *cr.Spec.Backups.Enabled) + }) +} + func TestPerconaPGCluster_BackupsEnabled(t *testing.T) { trueVal := true falseVal := false From 31e9f22a0f8fb63b83c2962cbb19d323df3b477a Mon Sep 17 00:00:00 2001 From: Viacheslav Sarzhan Date: Mon, 20 Jul 2026 12:40:32 +0300 Subject: [PATCH 4/4] fix comment --- pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go index 33af960cf..70178a8d4 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types_test.go @@ -27,7 +27,7 @@ func TestPerconaPGCluster_Default(t *testing.T) { func TestPerconaPGCluster_DefaultBackupsEnabled(t *testing.T) { t.Run("nil is defaulted to true for CRVersion >= 3.1.0", func(t *testing.T) { cr := new(PerconaPGCluster) - cr.Spec.CRVersion = "3.1.0" + cr.Spec.CRVersion = version.Version() cr.Default() require.NotNil(t, cr.Spec.Backups.Enabled) @@ -44,7 +44,7 @@ func TestPerconaPGCluster_DefaultBackupsEnabled(t *testing.T) { t.Run("explicit false is preserved for CRVersion >= 3.1.0", func(t *testing.T) { cr := new(PerconaPGCluster) - cr.Spec.CRVersion = "3.1.0" + cr.Spec.CRVersion = version.Version() cr.Spec.Backups.Enabled = new(false) cr.Default()