Skip to content

fix(metrics): report sync replicas min/max with the new synchronous API - #11979

Merged
leonardoce merged 1 commit into
mainfrom
dev/11309
Nov 24, 2026
Merged

leonardoce merged 1 commit into
mainfrom
dev/11309

Conversation

@gbartolini

@gbartolini gbartolini commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

The min and max values of cnpg_collector_sync_replicas were always read from the legacy .spec.minSyncReplicas and .spec.maxSyncReplicas fields, so they were reported as 0 for clusters configured through .spec.postgresql.synchronous.

Derive them from the configured number instead when the new API is in use: both bounds equal number when data durability is required, while the minimum is 0 when it is preferred, as the number of synchronous replicas can then be lowered to what is available. The legacy configuration keeps reporting the legacy fields.

Refs #11309

Assisted-by: Claude

@gbartolini
gbartolini requested a review from a team as a code owner November 21, 2026 08:06
@cnpg-bot cnpg-bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@gbartolini

Copy link
Copy Markdown
Contributor Author

Verified on a kind cluster with 3 instances, method: any, number: 1:

State required observed preferred observed
healthy 2 2
one replica fenced 1 1
both replicas fenced 0 (was 1) 0

@github-actions

Copy link
Copy Markdown
Contributor

@gbartolini

Copy link
Copy Markdown
Contributor Author

/test

@github-actions

Copy link
Copy Markdown
Contributor

@gbartolini gbartolini added do not backport This PR must not be backported - it will be in the next minor release and removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 labels Nov 22, 2026
@gbartolini gbartolini added backport-requested ◀️ This pull request should be backported to all supported releases release-1.28 release-1.30 and removed do not backport This PR must not be backported - it will be in the next minor release labels Nov 23, 2026
@leonardoce

Copy link
Copy Markdown
Contributor

/test

@github-actions

Copy link
Copy Markdown
Contributor

The `min` and `max` values of `cnpg_collector_sync_replicas` were always
read from the legacy `.spec.minSyncReplicas` and `.spec.maxSyncReplicas`
fields, so they were reported as 0 for clusters configured through
`.spec.postgresql.synchronous`.

Derive them from the configured `number` instead when the new API is in
use: both bounds equal `number` when data durability is required, while
the minimum is 0 when it is preferred, as the number of synchronous
replicas can then be lowered to what is available. The legacy
configuration keeps reporting the legacy fields.

Part of #11309

Assisted-by: Claude

Signed-off-by: Gabriele Bartolini <[email protected]>
@cnpg-bot cnpg-bot added the ok to merge 👌 This PR can be merged label Nov 24, 2026
@leonardoce
leonardoce merged commit 20eae4e into main Nov 24, 2026
39 of 40 checks passed
@leonardoce
leonardoce deleted the dev/11309 branch November 24, 2026 10:29
leonardoce pushed a commit that referenced this pull request Nov 24, 2026
…PI (#11979)

The `min` and `max` values of `cnpg_collector_sync_replicas` were always
read from the legacy `.spec.minSyncReplicas` and `.spec.maxSyncReplicas`
fields, so they were reported as 0 for clusters configured through
`.spec.postgresql.synchronous`.

Derive them from the configured `number` instead when the new API is in
use: both bounds equal `number` when data durability is required, while
the minimum is 0 when it is preferred, as the number of synchronous
replicas can then be lowered to what is available. The legacy
configuration keeps reporting the legacy fields.

Refs #11309

Assisted-by: Claude

Signed-off-by: Gabriele Bartolini <[email protected]>
(cherry picked from commit 20eae4e)
mnencia pushed a commit that referenced this pull request Nov 24, 2026
…PI (#11979)

The `min` and `max` values of `cnpg_collector_sync_replicas` were always
read from the legacy `.spec.minSyncReplicas` and `.spec.maxSyncReplicas`
fields, so they were reported as 0 for clusters configured through
`.spec.postgresql.synchronous`.

Derive them from the configured `number` instead when the new API is in
use: both bounds equal `number` when data durability is required, while
the minimum is 0 when it is preferred, as the number of synchronous
replicas can then be lowered to what is available. The legacy
configuration keeps reporting the legacy fields.

Refs #11309

Assisted-by: Claude

Signed-off-by: Gabriele Bartolini <[email protected]>
(cherry picked from commit 20eae4e)
mnencia added a commit that referenced this pull request Nov 24, 2026
Move the observed metric change to Important changes and point to the
upgrade section once. Drop the internal status-port flag and the date of
PostgreSQL 19, explain the deprecated role password fields, and cut
repeated text. Mark #11979 as backported to 1.28.

Signed-off-by: Marco Nenciarini <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-requested ◀️ This pull request should be backported to all supported releases ok to merge 👌 This PR can be merged release-1.28 release-1.30

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: cnpg_collector_sync_replicas{min,max} report stale/incorrect values when using the new synchronous replication API

4 participants