K8SPG-1062: treat pgbouncer with 0 replicas as disabled#1670
Open
pooknull wants to merge 4 commits into
Open
Conversation
pooknull
marked this pull request as ready for review
July 14, 2026 10:09
pooknull
requested review from
egegunes,
gkech,
hors,
mayankshah1607,
nmarukovich and
oksana-grishchenko
as code owners
July 14, 2026 10:09
egegunes
approved these changes
Jul 15, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses K8SPG-1062 by making the operator treat PgBouncer configured with replicas: 0 as disabled, preventing the Pg endpoint/host selection and reconciliation from continuing to target or maintain PgBouncer resources when it is intentionally scaled to zero.
Changes:
- Added
PGBouncerEnabled()helpers to both upstream (v1beta1) and Percona (v2) proxy specs to centralize the “replicas == 0 means disabled” logic. - Updated host selection and PgBouncer reconciliation paths to use
PGBouncerEnabled()instead of only checking for nil proxy/PgBouncer configs. - Added unit test coverage for the “zero replicas” behavior in host selection and PgBouncer Service generation.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/apis/upstream.pgv2.percona.com/v1beta1/postgrescluster_types.go | Adds PostgresProxySpec.PGBouncerEnabled() to treat replicas: 0 as disabled for upstream clusters. |
| pkg/apis/pgv2.percona.com/v2/perconapgcluster_types.go | Adds PGProxySpec.PGBouncerEnabled() for Percona CRD usage. |
| percona/controller/pgcluster/status.go | Uses PGBouncerEnabled() to select primary service host when PgBouncer is effectively disabled. |
| percona/controller/pgcluster/gethost_test.go | Adds a test case ensuring replicas: 0 results in primary-service host selection. |
| internal/pgbouncer/reconcile.go | Skips PgBouncer asset reconciliation when PGBouncerEnabled() is false. |
| internal/controller/postgrescluster/postgres.go | Avoids adding PgBouncer connection info to user secrets when replicas: 0. |
| internal/controller/postgrescluster/pgbouncer.go | Treats replicas: 0 like disabled across PgBouncer resource reconciliation (create/update vs delete). |
| internal/controller/postgrescluster/pgbouncer_test.go | Adds a test ensuring PgBouncer Service is not “specified” when replicas: 0. |
nmarukovich
approved these changes
Jul 17, 2026
Collaborator
commit: 5ae8a8d |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://perconadev.atlassian.net/browse/K8SPG-1062
DESCRIPTION
Problem:
When pgbouncer is scaled down to 0, it's service remains and pg endpoint is still points to the pgbouncer service.
Solution:
Operator should treat pgbouncer with 0 size as disabled throughout the operator.
CHECKLIST
Jira
Needs Doc) and QA (Needs QA)?Tests
Config/Logging/Testability