From 67331e4c6e84cc40bd352848b20da6e765316c54 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Mon, 2 Dec 2024 08:24:01 +0100 Subject: [PATCH 01/12] Add AutoCreateUserSchema field. --- .../pgv2.percona.com/v2/perconapgcluster_types.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index b7f063ebf6..c034e2cbe3 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -12,6 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "github.com/percona/percona-postgresql-operator/internal/logging" + "github.com/percona/percona-postgresql-operator/internal/naming" pNaming "github.com/percona/percona-postgresql-operator/percona/naming" crunchyv1beta1 "github.com/percona/percona-postgresql-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1" ) @@ -166,6 +167,11 @@ type PerconaPGClusterSpec struct { // +operator-sdk:csv:customresourcedefinitions:type=spec // +optional Extensions ExtensionsSpec `json:"extensions,omitempty"` + + // Whether or not the cluster has schemas automatically created for the user + // defined in `spec.users` for all of the databases listed for that user. + // +optional + AutoCreateUserSchema *bool `json:"autoCreateUserSchema,omitempty"` } func (cr *PerconaPGCluster) Default() { @@ -247,6 +253,11 @@ func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crun annotations[pNaming.ToCrunchyAnnotation(k)] = v } } + + if *cr.Spec.AutoCreateUserSchema { + annotations[naming.AutoCreateUserSchemaAnnotation] = "true" + } + postgresCluster.Annotations = annotations postgresCluster.Labels = cr.Labels if postgresCluster.Labels == nil { From 67246fb7db72f39fbbc722c3d894a3bf8e27f4c8 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Mon, 2 Dec 2024 08:25:26 +0100 Subject: [PATCH 02/12] Generate CRDs. --- .../generated/pgv2.percona.com_perconapgclusters.yaml | 5 +++++ config/crd/bases/pgv2.percona.com_perconapgclusters.yaml | 5 +++++ deploy/bundle.yaml | 5 +++++ deploy/crd.yaml | 5 +++++ deploy/cw-bundle.yaml | 5 +++++ pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml b/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml index 7a6c7f7ad0..09d5a3bf6e 100644 --- a/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml +++ b/build/crd/percona/generated/pgv2.percona.com_perconapgclusters.yaml @@ -56,6 +56,11 @@ spec: type: object spec: properties: + autoCreateUserSchema: + description: |- + Whether or not the cluster has schemas automatically created for the user + defined in `spec.users` for all of the databases listed for that user. + type: boolean backups: description: PostgreSQL backup configuration properties: diff --git a/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml b/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml index b97a1cdedb..600ec47c2a 100644 --- a/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml +++ b/config/crd/bases/pgv2.percona.com_perconapgclusters.yaml @@ -462,6 +462,11 @@ spec: type: object spec: properties: + autoCreateUserSchema: + description: |- + Whether or not the cluster has schemas automatically created for the user + defined in `spec.users` for all of the databases listed for that user. + type: boolean backups: description: PostgreSQL backup configuration properties: diff --git a/deploy/bundle.yaml b/deploy/bundle.yaml index 8d75cd6227..8b9618b1d2 100644 --- a/deploy/bundle.yaml +++ b/deploy/bundle.yaml @@ -755,6 +755,11 @@ spec: type: object spec: properties: + autoCreateUserSchema: + description: |- + Whether or not the cluster has schemas automatically created for the user + defined in `spec.users` for all of the databases listed for that user. + type: boolean backups: description: PostgreSQL backup configuration properties: diff --git a/deploy/crd.yaml b/deploy/crd.yaml index ab09163642..7d9ee0536b 100644 --- a/deploy/crd.yaml +++ b/deploy/crd.yaml @@ -755,6 +755,11 @@ spec: type: object spec: properties: + autoCreateUserSchema: + description: |- + Whether or not the cluster has schemas automatically created for the user + defined in `spec.users` for all of the databases listed for that user. + type: boolean backups: description: PostgreSQL backup configuration properties: diff --git a/deploy/cw-bundle.yaml b/deploy/cw-bundle.yaml index 873b4c22d3..1b8eef4dea 100644 --- a/deploy/cw-bundle.yaml +++ b/deploy/cw-bundle.yaml @@ -755,6 +755,11 @@ spec: type: object spec: properties: + autoCreateUserSchema: + description: |- + Whether or not the cluster has schemas automatically created for the user + defined in `spec.users` for all of the databases listed for that user. + type: boolean backups: description: PostgreSQL backup configuration properties: diff --git a/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go b/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go index 1468283730..1c1f6865eb 100644 --- a/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go +++ b/pkg/apis/pgv2.percona.com/v2/zz_generated.deepcopy.go @@ -741,6 +741,11 @@ func (in *PerconaPGClusterSpec) DeepCopyInto(out *PerconaPGClusterSpec) { (*in).DeepCopyInto(*out) } in.Extensions.DeepCopyInto(&out.Extensions) + if in.AutoCreateUserSchema != nil { + in, out := &in.AutoCreateUserSchema, &out.AutoCreateUserSchema + *out = new(bool) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PerconaPGClusterSpec. From 4a6c1028b9215c183bee8f31d0dba30a4b00c7d1 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Mon, 2 Dec 2024 08:38:25 +0100 Subject: [PATCH 03/12] Fix nil pointer. --- pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index c034e2cbe3..6c6eedc941 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -254,7 +254,7 @@ func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crun } } - if *cr.Spec.AutoCreateUserSchema { + if cr.Spec.AutoCreateUserSchema != nil && *cr.Spec.AutoCreateUserSchema { annotations[naming.AutoCreateUserSchemaAnnotation] = "true" } From e4de0d847953e9929a4d9179abec824794ce1690 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 08:29:47 +0100 Subject: [PATCH 04/12] Update cr.yaml. --- deploy/cr.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deploy/cr.yaml b/deploy/cr.yaml index 47c629bb48..1957ccb838 100644 --- a/deploy/cr.yaml +++ b/deploy/cr.yaml @@ -28,6 +28,8 @@ spec: # openshift: true +# autoCreateUserSchema: true + # users: # - name: rhino # databases: From 3c853cfb5656fc83354140ee0fc487d83f283472 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 08:31:54 +0100 Subject: [PATCH 05/12] Fix CR --- deploy/cr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/cr.yaml b/deploy/cr.yaml index 1957ccb838..2f61b5f6fd 100644 --- a/deploy/cr.yaml +++ b/deploy/cr.yaml @@ -28,7 +28,7 @@ spec: # openshift: true -# autoCreateUserSchema: true +# autoCreateUserSchema: true # users: # - name: rhino From f5dbbaa0f515d21b1bc8230fec470901f4aa57d8 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 09:26:31 +0100 Subject: [PATCH 06/12] Update users e2e test. --- e2e-tests/tests/users/07-add-custom-user.yaml | 2 +- e2e-tests/tests/users/08-write-data-to-custom-db.yaml | 5 +++-- e2e-tests/tests/users/09-read-from-primary-custom-db.yaml | 3 ++- e2e-tests/tests/users/11-write-data-to-custom-db.yaml | 3 ++- e2e-tests/tests/users/12-read-from-primary-custom-db.yaml | 3 ++- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/e2e-tests/tests/users/07-add-custom-user.yaml b/e2e-tests/tests/users/07-add-custom-user.yaml index a621d50c3b..6bbfc20810 100644 --- a/e2e-tests/tests/users/07-add-custom-user.yaml +++ b/e2e-tests/tests/users/07-add-custom-user.yaml @@ -8,5 +8,5 @@ commands: source ../../functions - kubectl -n ${NAMESPACE} patch perconapgcluster/${test_name} --type=json -p '[{"op":"add", "path":"/spec/users","value":[{"name":"rhino","databases":["zoo"],"password":{"type":"ASCII"},"secretName":"rhino-credentials"}]}]' + kubectl -n ${NAMESPACE} patch perconapgcluster/${test_name} --type=json -p '[{"op":"add", "path":"/spec/autoCreateUserSchema","value":true},{"op":"add", "path":"/spec/users","value":[{"name":"rhino","databases":["zoo"],"password":{"type":"ASCII"},"secretName":"rhino-credentials"}]}]' sleep 10 diff --git a/e2e-tests/tests/users/08-write-data-to-custom-db.yaml b/e2e-tests/tests/users/08-write-data-to-custom-db.yaml index 3c4af7e2b0..f240b8637a 100644 --- a/e2e-tests/tests/users/08-write-data-to-custom-db.yaml +++ b/e2e-tests/tests/users/08-write-data-to-custom-db.yaml @@ -10,13 +10,14 @@ commands: password=$(get_psql_user_pass rhino-credentials) user='rhino' db_name='zoo' + schema='rhino' hostname=$(get_pgbouncer_host rhino-credentials) run_psql \ - 'CREATE SCHEMA app CREATE TABLE IF NOT EXISTS customApp (id int PRIMARY KEY);' \ + 'CREATE TABLE IF NOT EXISTS customApp (id int PRIMARY KEY);' \ "-h $hostname -U $user -d $db_name" "$password" run_psql \ - 'INSERT INTO app.customApp (id) VALUES (100500)' \ + "INSERT INTO $schema.customApp (id) VALUES (100500)" \ "-h $hostname -U $user -d $db_name" "$password" diff --git a/e2e-tests/tests/users/09-read-from-primary-custom-db.yaml b/e2e-tests/tests/users/09-read-from-primary-custom-db.yaml index aee4ebd441..9ee89a304a 100644 --- a/e2e-tests/tests/users/09-read-from-primary-custom-db.yaml +++ b/e2e-tests/tests/users/09-read-from-primary-custom-db.yaml @@ -11,8 +11,9 @@ commands: password=$(get_psql_user_pass rhino-credentials) user='rhino' db_name='zoo' + schema='rhino' hostname=$(get_pgbouncer_host rhino-credentials) - data=$(run_psql 'SELECT * from app.customApp;' "-h $hostname -U $user -d $db_name" "$password") + data=$(run_psql "SELECT * from $schema.customApp;" "-h $hostname -U $user -d $db_name" "$password") kubectl create configmap -n "${NAMESPACE}" 09-read-from-primary-custom-db --from-literal=data="${data}" diff --git a/e2e-tests/tests/users/11-write-data-to-custom-db.yaml b/e2e-tests/tests/users/11-write-data-to-custom-db.yaml index 734259c622..768d3061ce 100644 --- a/e2e-tests/tests/users/11-write-data-to-custom-db.yaml +++ b/e2e-tests/tests/users/11-write-data-to-custom-db.yaml @@ -10,8 +10,9 @@ commands: password=$(get_psql_user_pass rhino-credentials) user='rhino' db_name='zoo' + schema='rhino' hostname=$(get_pgbouncer_host rhino-credentials) run_psql \ - 'INSERT INTO app.customApp (id) VALUES (100501)' \ + "INSERT INTO $schema.customApp (id) VALUES (100501)" \ "-h $hostname -U $user -d $db_name" "$password" diff --git a/e2e-tests/tests/users/12-read-from-primary-custom-db.yaml b/e2e-tests/tests/users/12-read-from-primary-custom-db.yaml index e41dc7a0d9..bfccdf36c6 100644 --- a/e2e-tests/tests/users/12-read-from-primary-custom-db.yaml +++ b/e2e-tests/tests/users/12-read-from-primary-custom-db.yaml @@ -11,7 +11,8 @@ commands: password=$(get_psql_user_pass rhino-credentials) user='rhino' db_name='zoo' + schema='rhino' hostname=$(get_pgbouncer_host rhino-credentials) - data=$(run_psql 'SELECT * from app.customApp;' "-h $hostname -U $user -d $db_name" "$password") + data=$(run_psql "SELECT * from $schema.customApp;" "-h $hostname -U $user -d $db_name" "$password") kubectl create configmap -n "${NAMESPACE}" 12-read-from-primary-custom-db --from-literal=data="${data}" From 8bbac107e75ae357347aff2c275e48da09ef7b03 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 11:10:02 +0100 Subject: [PATCH 07/12] Enable autoCreateUserSchema by default. --- deploy/cr.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/cr.yaml b/deploy/cr.yaml index 2f61b5f6fd..ee3b73cf99 100644 --- a/deploy/cr.yaml +++ b/deploy/cr.yaml @@ -28,7 +28,7 @@ spec: # openshift: true -# autoCreateUserSchema: true + autoCreateUserSchema: true # users: # - name: rhino From 9237c598a51ba4b95100c05d2717228885061c30 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 11:26:33 +0100 Subject: [PATCH 08/12] Enable AutoCreateUserSchema properly. --- deploy/cr.yaml | 2 +- pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/deploy/cr.yaml b/deploy/cr.yaml index ee3b73cf99..2f61b5f6fd 100644 --- a/deploy/cr.yaml +++ b/deploy/cr.yaml @@ -28,7 +28,7 @@ spec: # openshift: true - autoCreateUserSchema: true +# autoCreateUserSchema: true # users: # - name: rhino diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index 6c6eedc941..2686826133 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -224,6 +224,10 @@ func (cr *PerconaPGCluster) Default() { if cr.Spec.Extensions.BuiltIn.PGAudit == nil { cr.Spec.Extensions.BuiltIn.PGAudit = &t } + + if cr.CompareVersion("2.6.0") >= 0 && cr.Spec.AutoCreateUserSchema == nil { + cr.Spec.AutoCreateUserSchema = &t + } } func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crunchyv1beta1.PostgresCluster, scheme *runtime.Scheme) (*crunchyv1beta1.PostgresCluster, error) { @@ -254,7 +258,7 @@ func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crun } } - if cr.Spec.AutoCreateUserSchema != nil && *cr.Spec.AutoCreateUserSchema { + if *cr.Spec.AutoCreateUserSchema { annotations[naming.AutoCreateUserSchemaAnnotation] = "true" } From 7a53f31e08ced7fac68e4306fac74b7f77a160ac Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 11:38:31 +0100 Subject: [PATCH 09/12] Fix tests. --- percona/controller/pgcluster/testutils_test.go | 2 ++ percona/controller/testdata/sidecar-resources-cr.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/percona/controller/pgcluster/testutils_test.go b/percona/controller/pgcluster/testutils_test.go index 49076f2a66..9ea19f06dd 100644 --- a/percona/controller/pgcluster/testutils_test.go +++ b/percona/controller/pgcluster/testutils_test.go @@ -107,6 +107,8 @@ func readDefaultCR(name, namespace string) (*v2.PerconaPGCluster, error) { cr.Name = name cr.Namespace = namespace + t := true + cr.Spec.AutoCreateUserSchema = &t return cr, nil } diff --git a/percona/controller/testdata/sidecar-resources-cr.yaml b/percona/controller/testdata/sidecar-resources-cr.yaml index 2a363cb7ca..25f4f17bdd 100644 --- a/percona/controller/testdata/sidecar-resources-cr.yaml +++ b/percona/controller/testdata/sidecar-resources-cr.yaml @@ -10,6 +10,8 @@ spec: imagePullPolicy: Always postgresVersion: 16 + autoCreateUserSchema: true + instances: - name: instance1 replicas: 3 From a53d0f2623678f39d4bde49a93d8657200402e89 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Thu, 12 Dec 2024 12:00:56 +0100 Subject: [PATCH 10/12] Test updated. --- percona/controller/pgcluster/testutils_test.go | 2 -- percona/controller/testdata/sidecar-resources-cr.yaml | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/percona/controller/pgcluster/testutils_test.go b/percona/controller/pgcluster/testutils_test.go index 9ea19f06dd..49076f2a66 100644 --- a/percona/controller/pgcluster/testutils_test.go +++ b/percona/controller/pgcluster/testutils_test.go @@ -107,8 +107,6 @@ func readDefaultCR(name, namespace string) (*v2.PerconaPGCluster, error) { cr.Name = name cr.Namespace = namespace - t := true - cr.Spec.AutoCreateUserSchema = &t return cr, nil } diff --git a/percona/controller/testdata/sidecar-resources-cr.yaml b/percona/controller/testdata/sidecar-resources-cr.yaml index 25f4f17bdd..3cf523a664 100644 --- a/percona/controller/testdata/sidecar-resources-cr.yaml +++ b/percona/controller/testdata/sidecar-resources-cr.yaml @@ -4,14 +4,12 @@ kind: PerconaPGCluster metadata: name: cluster1 spec: - crVersion: 2.5.0 + crVersion: 2.6.0 image: perconalab/percona-postgresql-operator:main-ppg16-postgres imagePullPolicy: Always postgresVersion: 16 - autoCreateUserSchema: true - instances: - name: instance1 replicas: 3 From f05626124145a05f5323df843ddad8456b737770 Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Tue, 17 Dec 2024 12:51:15 +0100 Subject: [PATCH 11/12] Fix panic --- pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go index 2686826133..dddc1aed3e 100644 --- a/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go +++ b/pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go @@ -258,7 +258,7 @@ func (cr *PerconaPGCluster) ToCrunchy(ctx context.Context, postgresCluster *crun } } - if *cr.Spec.AutoCreateUserSchema { + if cr.Spec.AutoCreateUserSchema != nil && *cr.Spec.AutoCreateUserSchema { annotations[naming.AutoCreateUserSchemaAnnotation] = "true" } From 280bc2d811ca168778402a9e2202e5fd3fffa83f Mon Sep 17 00:00:00 2001 From: Inel Pandzic Date: Tue, 17 Dec 2024 16:18:00 +0100 Subject: [PATCH 12/12] Update upgrade-consistency test. --- .../tests/upgrade-consistency/01-assert.yaml | 2 +- .../01-create-cluster.yaml | 2 +- .../tests/upgrade-consistency/02-assert.yaml | 2 +- .../upgrade-consistency/02-patch-cluster.yaml | 2 +- .../tests/upgrade-consistency/03-assert.yaml | 2 +- .../upgrade-consistency/03-patch-cluster.yaml | 2 +- .../tests/upgrade-consistency/04-assert.yaml | 135 ------------------ .../upgrade-consistency/04-patch-cluster.yaml | 16 --- .../tests/upgrade-consistency/05-assert.yaml | 135 ------------------ .../upgrade-consistency/05-patch-cluster.yaml | 16 --- 10 files changed, 6 insertions(+), 308 deletions(-) delete mode 100644 e2e-tests/tests/upgrade-consistency/04-assert.yaml delete mode 100644 e2e-tests/tests/upgrade-consistency/04-patch-cluster.yaml delete mode 100644 e2e-tests/tests/upgrade-consistency/05-assert.yaml delete mode 100644 e2e-tests/tests/upgrade-consistency/05-patch-cluster.yaml diff --git a/e2e-tests/tests/upgrade-consistency/01-assert.yaml b/e2e-tests/tests/upgrade-consistency/01-assert.yaml index 26dcf45710..c7978a1313 100644 --- a/e2e-tests/tests/upgrade-consistency/01-assert.yaml +++ b/e2e-tests/tests/upgrade-consistency/01-assert.yaml @@ -122,7 +122,7 @@ kind: PerconaPGCluster metadata: name: upgrade-consistency spec: - crVersion: 2.1.0 + crVersion: 2.4.0 status: pgbouncer: ready: 3 diff --git a/e2e-tests/tests/upgrade-consistency/01-create-cluster.yaml b/e2e-tests/tests/upgrade-consistency/01-create-cluster.yaml index 6bffc104bd..cfb4cf5620 100644 --- a/e2e-tests/tests/upgrade-consistency/01-create-cluster.yaml +++ b/e2e-tests/tests/upgrade-consistency/01-create-cluster.yaml @@ -10,5 +10,5 @@ commands: get_cr \ | yq eval ' - .spec.crVersion="2.1.0"' - \ + .spec.crVersion="2.4.0"' - \ | kubectl -n "${NAMESPACE}" apply -f - diff --git a/e2e-tests/tests/upgrade-consistency/02-assert.yaml b/e2e-tests/tests/upgrade-consistency/02-assert.yaml index 3b9845d848..9b18571570 100644 --- a/e2e-tests/tests/upgrade-consistency/02-assert.yaml +++ b/e2e-tests/tests/upgrade-consistency/02-assert.yaml @@ -120,7 +120,7 @@ kind: PerconaPGCluster metadata: name: upgrade-consistency spec: - crVersion: 2.2.0 + crVersion: 2.5.0 status: pgbouncer: ready: 3 diff --git a/e2e-tests/tests/upgrade-consistency/02-patch-cluster.yaml b/e2e-tests/tests/upgrade-consistency/02-patch-cluster.yaml index e63465fb25..a5f90f4501 100644 --- a/e2e-tests/tests/upgrade-consistency/02-patch-cluster.yaml +++ b/e2e-tests/tests/upgrade-consistency/02-patch-cluster.yaml @@ -10,7 +10,7 @@ commands: get_cr \ | yq eval ' - .spec.crVersion="2.2.0"' - \ + .spec.crVersion="2.5.0"' - \ | kubectl -n "${NAMESPACE}" apply -f - sleep 10 diff --git a/e2e-tests/tests/upgrade-consistency/03-assert.yaml b/e2e-tests/tests/upgrade-consistency/03-assert.yaml index 0216e23957..9bfd8e1c97 100644 --- a/e2e-tests/tests/upgrade-consistency/03-assert.yaml +++ b/e2e-tests/tests/upgrade-consistency/03-assert.yaml @@ -120,7 +120,7 @@ kind: PerconaPGCluster metadata: name: upgrade-consistency spec: - crVersion: 2.3.0 + crVersion: 2.6.0 status: pgbouncer: ready: 3 diff --git a/e2e-tests/tests/upgrade-consistency/03-patch-cluster.yaml b/e2e-tests/tests/upgrade-consistency/03-patch-cluster.yaml index ec35b72a95..3c2c0cb7b6 100644 --- a/e2e-tests/tests/upgrade-consistency/03-patch-cluster.yaml +++ b/e2e-tests/tests/upgrade-consistency/03-patch-cluster.yaml @@ -10,7 +10,7 @@ commands: get_cr \ | yq eval ' - .spec.crVersion="2.3.0"' - \ + .spec.crVersion="2.6.0"' - \ | kubectl -n "${NAMESPACE}" apply -f - sleep 10 diff --git a/e2e-tests/tests/upgrade-consistency/04-assert.yaml b/e2e-tests/tests/upgrade-consistency/04-assert.yaml deleted file mode 100644 index 9d5c3124f3..0000000000 --- a/e2e-tests/tests/upgrade-consistency/04-assert.yaml +++ /dev/null @@ -1,135 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 240 ---- -kind: StatefulSet -apiVersion: apps/v1 -metadata: - name: upgrade-consistency-repo-host - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/data: pgbackrest - postgres-operator.crunchydata.com/pgbackrest: '' - postgres-operator.crunchydata.com/pgbackrest-dedicated: '' - ownerReferences: - - apiVersion: postgres-operator.crunchydata.com/v1beta1 - kind: PostgresCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true -status: - observedGeneration: 4 - replicas: 1 - readyReplicas: 1 - updatedReplicas: 1 - collisionCount: 0 ---- -kind: StatefulSet -apiVersion: apps/v1 -metadata: - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/data: postgres - postgres-operator.crunchydata.com/instance-set: instance1 - ownerReferences: - - apiVersion: postgres-operator.crunchydata.com/v1beta1 - kind: PostgresCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true -status: - observedGeneration: 4 - replicas: 1 - readyReplicas: 1 - updatedReplicas: 1 - collisionCount: 0 ---- -kind: Deployment -apiVersion: apps/v1 -metadata: - name: upgrade-consistency-pgbouncer - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/role: pgbouncer - annotations: - deployment.kubernetes.io/revision: '4' - ownerReferences: - - apiVersion: postgres-operator.crunchydata.com/v1beta1 - kind: PostgresCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true -status: - observedGeneration: 4 - replicas: 3 - updatedReplicas: 3 - readyReplicas: 3 ---- -kind: Job -apiVersion: batch/v1 -metadata: - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/pgbackrest: '' - postgres-operator.crunchydata.com/pgbackrest-backup: replica-create - postgres-operator.crunchydata.com/pgbackrest-repo: repo1 - ownerReferences: - - apiVersion: pgv2.percona.com/v2 - kind: PerconaPGBackup - controller: true - blockOwnerDeletion: true -status: - succeeded: 1 ---- -apiVersion: postgres-operator.crunchydata.com/v1beta1 -kind: PostgresCluster -metadata: - name: upgrade-consistency - ownerReferences: - - apiVersion: pgv2.percona.com/v2 - kind: PerconaPGCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true - finalizers: - - postgres-operator.crunchydata.com/finalizer -status: - instances: - - name: instance1 - readyReplicas: 3 - replicas: 3 - updatedReplicas: 3 - observedGeneration: 4 - pgbackrest: - repoHost: - apiVersion: apps/v1 - kind: StatefulSet - ready: true - repos: - - bound: true - name: repo1 - replicaCreateBackupComplete: true - stanzaCreated: true - proxy: - pgBouncer: - readyReplicas: 3 - replicas: 3 ---- -apiVersion: pgv2.percona.com/v2 -kind: PerconaPGCluster -metadata: - name: upgrade-consistency -spec: - crVersion: 2.4.0 -status: - pgbouncer: - ready: 3 - size: 3 - postgres: - instances: - - name: instance1 - ready: 3 - size: 3 - ready: 3 - size: 3 - state: ready diff --git a/e2e-tests/tests/upgrade-consistency/04-patch-cluster.yaml b/e2e-tests/tests/upgrade-consistency/04-patch-cluster.yaml deleted file mode 100644 index 16de5cdd9d..0000000000 --- a/e2e-tests/tests/upgrade-consistency/04-patch-cluster.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval ' - .spec.crVersion="2.4.0"' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - sleep 10 diff --git a/e2e-tests/tests/upgrade-consistency/05-assert.yaml b/e2e-tests/tests/upgrade-consistency/05-assert.yaml deleted file mode 100644 index 4a8aef6e28..0000000000 --- a/e2e-tests/tests/upgrade-consistency/05-assert.yaml +++ /dev/null @@ -1,135 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestAssert -timeout: 240 ---- -kind: StatefulSet -apiVersion: apps/v1 -metadata: - name: upgrade-consistency-repo-host - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/data: pgbackrest - postgres-operator.crunchydata.com/pgbackrest: '' - postgres-operator.crunchydata.com/pgbackrest-dedicated: '' - ownerReferences: - - apiVersion: postgres-operator.crunchydata.com/v1beta1 - kind: PostgresCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true -status: - observedGeneration: 5 - replicas: 1 - readyReplicas: 1 - updatedReplicas: 1 - collisionCount: 0 ---- -kind: StatefulSet -apiVersion: apps/v1 -metadata: - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/data: postgres - postgres-operator.crunchydata.com/instance-set: instance1 - ownerReferences: - - apiVersion: postgres-operator.crunchydata.com/v1beta1 - kind: PostgresCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true -status: - observedGeneration: 5 - replicas: 1 - readyReplicas: 1 - updatedReplicas: 1 - collisionCount: 0 ---- -kind: Deployment -apiVersion: apps/v1 -metadata: - name: upgrade-consistency-pgbouncer - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/role: pgbouncer - annotations: - deployment.kubernetes.io/revision: '5' - ownerReferences: - - apiVersion: postgres-operator.crunchydata.com/v1beta1 - kind: PostgresCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true -status: - observedGeneration: 5 - replicas: 3 - updatedReplicas: 3 - readyReplicas: 3 ---- -kind: Job -apiVersion: batch/v1 -metadata: - labels: - postgres-operator.crunchydata.com/cluster: upgrade-consistency - postgres-operator.crunchydata.com/pgbackrest: '' - postgres-operator.crunchydata.com/pgbackrest-backup: replica-create - postgres-operator.crunchydata.com/pgbackrest-repo: repo1 - ownerReferences: - - apiVersion: pgv2.percona.com/v2 - kind: PerconaPGBackup - controller: true - blockOwnerDeletion: true -status: - succeeded: 1 ---- -apiVersion: postgres-operator.crunchydata.com/v1beta1 -kind: PostgresCluster -metadata: - name: upgrade-consistency - ownerReferences: - - apiVersion: pgv2.percona.com/v2 - kind: PerconaPGCluster - name: upgrade-consistency - controller: true - blockOwnerDeletion: true - finalizers: - - postgres-operator.crunchydata.com/finalizer -status: - instances: - - name: instance1 - readyReplicas: 3 - replicas: 3 - updatedReplicas: 3 - observedGeneration: 5 - pgbackrest: - repoHost: - apiVersion: apps/v1 - kind: StatefulSet - ready: true - repos: - - bound: true - name: repo1 - replicaCreateBackupComplete: true - stanzaCreated: true - proxy: - pgBouncer: - readyReplicas: 3 - replicas: 3 ---- -apiVersion: pgv2.percona.com/v2 -kind: PerconaPGCluster -metadata: - name: upgrade-consistency -spec: - crVersion: 2.5.0 -status: - pgbouncer: - ready: 3 - size: 3 - postgres: - instances: - - name: instance1 - ready: 3 - size: 3 - ready: 3 - size: 3 - state: ready diff --git a/e2e-tests/tests/upgrade-consistency/05-patch-cluster.yaml b/e2e-tests/tests/upgrade-consistency/05-patch-cluster.yaml deleted file mode 100644 index a5f90f4501..0000000000 --- a/e2e-tests/tests/upgrade-consistency/05-patch-cluster.yaml +++ /dev/null @@ -1,16 +0,0 @@ -apiVersion: kuttl.dev/v1beta1 -kind: TestStep -timeout: 30 -commands: - - script: |- - set -o errexit - set -o xtrace - - source ../../functions - - get_cr \ - | yq eval ' - .spec.crVersion="2.5.0"' - \ - | kubectl -n "${NAMESPACE}" apply -f - - - sleep 10