Repository navigation
feat(warn): alert users when a multi-instance cluster has no synchronous replication - #11148
Merged
Merged
Conversation
Contributor
|
❗ By default, the pull request is configured to backport to all release branches.
|
Member
|
/test |
Contributor
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/29032156805 |
gbartolini
force-pushed
the
warn-users-sync
branch
from
July 14, 2026 05:00
8937a9b to
69f26ce
Compare
gbartolini
approved these changes
Jul 14, 2026
gbartolini
force-pushed
the
warn-users-sync
branch
from
July 14, 2026 12:15
837b997 to
ebea3a4
Compare
armru
approved these changes
Jul 14, 2026
fcanovai
approved these changes
Jul 17, 2026
Member
|
/test |
Contributor
|
@mnencia, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/29844651663 |
…ous replication Multi-instance clusters without synchronous replication are silently exposed to data loss on primary failure: transactions not yet replicated to a standby will be lost when the primary's availability zone goes down. Add a webhook warning to make this risk visible at apply time, targeting users who deploy a cluster expecting HA and data safety without knowing that async replication does not guarantee durability. The warning is suppressed when either the current (.spec.postgresql.synchronous) or the legacy (.spec.minSyncReplicas) synchronous replication API is configured. Signed-off-by: Leonardo Cecchi <[email protected]>
The legacy API enables synchronous replication when maxSyncReplicas is greater than zero, while minSyncReplicas is only the floor applied when not enough replicas are ready, and validation requires minSyncReplicas to be lower than or equal to maxSyncReplicas. Checking minSyncReplicas alone made the warning fire for clusters that run quorum-based synchronous replication with maxSyncReplicas set and minSyncReplicas left at its default of zero. Signed-off-by: Armando Ruocco <[email protected]>
… only Raising it on every update would repeat the warning on each kubectl apply and on every patch of the cluster resource, including the ones issued by the operator and by the plugin. Raising it when the cluster is created is enough to make the risk visible. Signed-off-by: Armando Ruocco <[email protected]>
… clusters A replica cluster replays data coming from another cluster, so losing its designated primary doesn't lose data from the topology and the suggestion to configure synchronous replication doesn't apply. Signed-off-by: Armando Ruocco <[email protected]>
Explain that enabling synchronous replication requires enough standby servers to tolerate the loss of one of them, recommend planning for it in clusters with at least three instances, and point smaller clusters to the preferred data durability setting. Signed-off-by: Armando Ruocco <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Francesco Canovai <[email protected]>
Restoring the check to every apply, not just creation, is the only way it can catch the transition that matters most: a cluster losing its synchronous replication configuration, whether through an update that clears .spec.postgresql.synchronous or through scaling to two or more instances. A one-shot check at creation time leaves that change completely silent, which defeats the purpose of the warning. The legacy-API suppression is also keyed off minSyncReplicas again instead of maxSyncReplicas. The self-healing logic in getSyncReplicasData drops the effective synchronous requirement to minSyncReplicas whenever fewer replicas are ready than maxSyncReplicas, and minSyncReplicas defaults to zero. A cluster with only maxSyncReplicas set therefore loses its durability guarantee during any transient replica outage, such as a rolling update or a node drain, which is exactly the risk this warning exists to surface. Signed-off-by: Marco Nenciarini <[email protected]>
Neither fix in the previous commit had a regression test: reverting either the minSyncReplicas check or the create/update wiring back to the old behavior still left the full suite green. Add a case for a cluster with only maxSyncReplicas set, one at the Instances == 2 boundary, and one asserting the warning is returned by both ValidateCreate and ValidateUpdate. Signed-off-by: Marco Nenciarini <[email protected]>
…re in e2e AssertClusterDefault re-validates a just-created cluster and expects zero admission warnings, on the assumption that any warning means defaulting is broken. The e2e fixtures it's used with are multi-instance clusters that intentionally don't configure synchronous replication, so they now trip the new warning and fail this unrelated assertion. Accept that one specific warning while still failing on anything else. Signed-off-by: Marco Nenciarini <[email protected]>
Member
|
/test |
Contributor
|
@mnencia, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/29998257060 |
cluster-example.yaml, and its inline copy in the quickstart guide, are the template most users start a cluster from. Left as-is, applying it now trips the new missing-synchronous-replication warning on a three-instance cluster. Enable quorum-based synchronous replication with one required standby, the configuration replication.md already uses as the reference example for this exact template. Signed-off-by: Marco Nenciarini <[email protected]>
2 tasks done
Closed
4 tasks done
gbartolini
pushed a commit
to leonardoce/cloudnative-pg
that referenced
this pull request
Aug 10, 2026
…ication The warning fired on any multi-instance cluster with default configuration, making the webhook end-to-end test fail. The change is independently proposed in cloudnative-pg#11148, where its design is being discussed: this PR stays focused on failure domain-aware synchronous replication. Signed-off-by: Armando Ruocco <[email protected]>
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.
Multi-instance clusters without synchronous replication are silently exposed to data loss on primary failure: transactions not yet replicated to a standby will be lost when the primary's availability zone goes down.
Add a webhook warning to make this risk visible at apply time. The warning is suppressed when either the current (.spec.postgresql.synchronous) or the legacy (.spec.minSyncReplicas) synchronous replication API is configured.
Closes #11180