percona-postgresql-operator icon indicating copy to clipboard operation
percona-postgresql-operator copied to clipboard

K8SPG-217: Fix missing primary deployment after restore

Open egegunes opened this issue 3 years ago • 1 comments

The problem only occurs if primary is failed over to a replica before the restore.

The operator stores the current primary in an annotation of pgcluster (i.e. current-primary: cluster1). After the bootstrap finishes, operator creates the primary deployment using this value as the deployment name. After the primary is created, it proceeds to create replica deployments.

If a failover is performed and a replica deployment is promoted to primary, the operator updates the annotation (i.e. current-primary: cluster1-repl2).

If a restore is started at this moment in the cluster:

  1. Bootstrap finishes
  2. Operator creates cluster1-repl2 as the primary deployment
  3. Operator creates Pgreplica objects, cluster1-repl1 is created but cluster1-repl2 is skipped since it already exists

This commit updates the current-primary annotation with cluster name just before the restore, so restore is performed on PVC cluster1 and replicas are created as expected.

egegunes avatar Aug 11 '22 07:08 egegunes

Test name Status
demand-backup passed
scheduled-backup passed
version-service passed
init-deploy passed
upgrade passed
smart-update passed
scaling passed
recreate passed
affinity passed
monitoring passed
self-healing passed
operator-self-healing passed
clone-cluster passed
tls-check passed
users passed
ns-mode passed
We run 16 out of 16

commit: https://github.com/percona/percona-postgresql-operator/pull/295/commits/5516942628ea4933f2d827cbda1c297257b5c6ef image: perconalab/percona-postgresql-operator:PR-295-55169426-pgo-apiserver

image: perconalab/percona-postgresql-operator:PR-295-55169426-pgo-event

image: perconalab/percona-postgresql-operator:PR-295-55169426-pgo-rmdata

image: perconalab/percona-postgresql-operator:PR-295-55169426-pgo-scheduler

image: perconalab/percona-postgresql-operator:PR-295-55169426-postgres-operator

image: perconalab/percona-postgresql-operator:PR-295-55169426-pgo-deployer

JNKPercona avatar Aug 11 '22 12:08 JNKPercona