Preserve sync quorum in primary PDB without master selector (#3119)
* Use minAvalable=SynchronousNodeCount + 1 in primary PDB when master selector is disabled --------- Co-authored-by: Felix Kunde <felix-kunde@gmx.de> Co-authored-by: Ida Novindasari <idanovinda@gmail.com>
This commit is contained in:
parent
7578f9d2c0
commit
5c6dcc65e2
|
|
@ -2278,6 +2278,12 @@ func (c *Cluster) generatePrimaryPodDisruptionBudget() *policyv1.PodDisruptionBu
|
|||
labels[c.OpConfig.PodRoleLabel] = string(Master)
|
||||
}
|
||||
|
||||
// When master selector is disabled and synchronous_mode_strict is on, require
|
||||
// master + synchronous_node_count (default 1) healthy pods for write quorum.
|
||||
if pdbMasterLabelSelector != nil && !*pdbMasterLabelSelector && minAvailable.IntVal > 0 && c.Spec.SynchronousModeStrict {
|
||||
minAvailable = intstr.FromInt32(int32(c.Spec.SynchronousNodeCount + 1))
|
||||
}
|
||||
|
||||
return &policyv1.PodDisruptionBudget{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: c.PrimaryPodDisruptionBudgetName(),
|
||||
|
|
|
|||
|
|
@ -2691,13 +2691,13 @@ func TestGeneratePodDisruptionBudget(t *testing.T) {
|
|||
k8sutil.KubernetesClient{},
|
||||
acidv1.Postgresql{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: "myapp-database", Namespace: "myapp"},
|
||||
Spec: acidv1.PostgresSpec{TeamID: "myapp", NumberOfInstances: 3}},
|
||||
Spec: acidv1.PostgresSpec{TeamID: "myapp", NumberOfInstances: 3, Patroni: acidv1.Patroni{SynchronousModeStrict: true, SynchronousNodeCount: 1}}},
|
||||
logger,
|
||||
eventRecorder),
|
||||
check: []func(cluster *Cluster, podDisruptionBudget *policyv1.PodDisruptionBudget) error{
|
||||
testPodDisruptionBudgetOwnerReference,
|
||||
hasName("postgres-myapp-database-pdb"),
|
||||
hasMinAvailable(1),
|
||||
hasMinAvailable(2),
|
||||
testLabelsAndSelectors(true),
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue