Skip to content

K8SPG-1099 clear inner PostgresCluster standby when spec.standby removed - #1823

Merged
egegunes merged 1 commit into
percona:mainfrom
KR-Ravindra:K8SPG-1099-clear-standby-on-removal
Oct 6, 2026
Merged

egegunes merged 1 commit into
percona:mainfrom
KR-Ravindra:K8SPG-1099-clear-standby-on-removal

Conversation

@KR-Ravindra

@KR-Ravindra KR-Ravindra commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

CHANGE DESCRIPTION

Problem

When spec.standby is removed from a PerconaPGCluster, the inner PostgresCluster keeps its previous spec.standby (enabled: true), so the cluster stays in standby and never promotes even though the user's CR no longer asks for it. The workaround today is to set spec.standby.enabled: false explicitly instead of deleting the block.

Cause

PerconaPGCluster.ToCrunchy() only assigns postgresCluster.Spec.Standby when cr.Spec.Standby != nil. ToCrunchy runs inside the CreateOrUpdate mutate function, so it operates on the live PostgresCluster fetched from the API server; with no else branch, a Standby set on an earlier reconcile is never cleared. Neighbouring fields (Paused, Shutdown, DataSource, Patroni) are assigned unconditionally and do not have this problem.

Solution

Reset postgresCluster.Spec.Standby to nil before the conditional assignment, so the inner cluster always mirrors the PerconaPGCluster. One line, no API or CRD changes.

A case added to TestPerconaPGCluster_ToCrunchy starts from a PostgresCluster with Standby set and a PerconaPGCluster with none, and asserts the result is nil.

Links

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly? (K8SPG-1099, created by the maintainers from the issue above)
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files? (no option changes)
  • Are all needed new/changed options added to the Helm Chart? (no option changes)
  • Did we add proper logging messages for operator actions? (no new actions)
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported PG version?
  • Does the change support oldest and newest supported Kubernetes version?

Yes, AI-assisted; reviewed by me.

@it-percona-cla

it-percona-cla commented Sep 9, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@KR-Ravindra
KR-Ravindra marked this pull request as ready for review September 9, 2026 16:16
@egegunes egegunes added this to the v3.2.0 milestone Sep 14, 2026
ToCrunchy() only assigned postgresCluster.Spec.Standby when the
PerconaPGCluster had spec.standby set. Because ToCrunchy mutates the live
PostgresCluster inside controllerutil.CreateOrUpdate, a standby block that
was later removed from the PerconaPGCluster stayed on the inner object and
the cluster never left standby mode.

Reset Spec.Standby before the conditional assignment so the inner
PostgresCluster always mirrors the PerconaPGCluster, and add a ToCrunchy
unit test covering removal of spec.standby.
@KR-Ravindra
KR-Ravindra force-pushed the K8SPG-1099-clear-standby-on-removal branch from 45d30d1 to 60244fe Compare September 20, 2026 21:42
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
backup-enable-disable passed 00:16:58
builtin-extensions passed 00:07:05
custom-extensions passed 00:20:39
cert-manager-tls passed 00:12:47
cert-management-policy passed 00:05:43
custom-envs passed 00:21:08
custom-tls passed 00:07:21
database-init-sql passed 00:02:39
demand-backup passed 00:23:26
demand-backup-offline-snapshot passed 00:15:13
dynamic-configuration passed 00:03:30
extra-volumes passed 00:03:50
finalizers passed 00:04:29
init-deploy passed 00:03:12
huge-pages passed 00:03:36
logical-replica passed 00:14:15
major-upgrade-14-to-15 passed 00:10:43
major-upgrade-15-to-16 passed 00:11:49
major-upgrade-16-to-17 passed 00:11:08
major-upgrade-17-to-18 passed 00:17:29
major-upgrade-logical-replica passed 00:11:17
ldap passed 00:06:08
ldap-tls passed 00:06:21
logcollection passed 00:08:28
monitoring passed 00:10:34
operator-upgrade-cert-manager passed 00:12:36
operator-upgrade-extensions passed 00:11:45
one-pod passed 00:06:07
repo-host-autogrow passed 00:01:54
operator-self-healing passed 00:11:39
pgbouncer passed 00:08:35
pg-tde passed 00:13:11
pg-tde-wal-encrypt passed 00:17:31
pitr passed 00:13:01
scaling passed 00:05:49
scheduled-backup passed 00:26:19
self-healing passed 00:10:29
sidecars passed 00:02:58
standby-pgbackrest passed 00:21:26
standby-streaming passed 00:18:30
start-from-backup passed 00:11:16
start-from-volumes passed 00:04:04
tablespaces passed 00:08:06
telemetry-transfer passed 00:05:04
upgrade-consistency passed 00:06:25
upgrade-minor passed 00:15:05
users passed 00:05:59
migration-from-crunchy-standby passed 00:19:30
migration-from-crunchy-pv passed 00:09:32
migration-from-crunchy-backup-restore passed 00:17:08
Summary Value
Tests Run 50/50
Job Duration 01:47:36
Total Test Time 09:04:15

commit: 60244fe
image: perconalab/percona-postgresql-operator:PR-1823-60244fe49

@KR-Ravindra

Copy link
Copy Markdown
Contributor Author

@gkech @mayankshah1607 this has one approval and a clean Jenkins run; could one of you take the second review when you have a moment?

Drafted with AI assistance and checked against the code.

@egegunes
egegunes merged commit 2a52caa into percona:main Oct 6, 2026
14 checks passed
@egegunes

egegunes commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@KR-Ravindra thank you for your contribution!

@zverulacis

Copy link
Copy Markdown

@KR-Ravindra, thank you for your contributions. As a token of our appreciation, we'd like to send you a Percona contributor challenge coin.

To receive it, fill in this form: https://forms.gle/b5qovTkTGVod6e2YA (or email [email protected] with the link to this PR).

Then leave a quick "done" here so we know it's you. And send us a pic when the coin arrives 📸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PerconaPGCluster standby removal not propagated to inner PostgresCluster — cluster stuck in standby after spec.standby removed

7 participants