Allow configuration of patroni's replication mode (#869)
* Add patroni parameters for `synchronous_mode` * Update complete-postgres-manifest.yaml, removed quotation marks * Update k8sres_test.go, adjust result for `Patroni configured` * Update k8sres_test.go, adjust result for `Patroni configured` * Update complete-postgres-manifest.yaml, set synchronous mode to false in this example * Update pkg/cluster/k8sres.go Does the same but is shorter. So we fix that it if you like. Co-Authored-By: Felix Kunde <felix-kunde@gmx.de> * Update docs/reference/cluster_manifest.md Co-Authored-By: Felix Kunde <felix-kunde@gmx.de> * Add patroni's `synchronous_mode_strict` * Extend `TestGenerateSpiloConfig` with `SynchronousModeStrict` Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
This commit is contained in:
parent
64389b8bad
commit
4dee8918bd
|
|
@ -218,6 +218,10 @@ spec:
|
||||||
type: integer
|
type: integer
|
||||||
retry_timeout:
|
retry_timeout:
|
||||||
type: integer
|
type: integer
|
||||||
|
synchronous_mode:
|
||||||
|
type: boolean
|
||||||
|
synchronous_mode_strict:
|
||||||
|
type: boolean
|
||||||
maximum_lag_on_failover:
|
maximum_lag_on_failover:
|
||||||
type: integer
|
type: integer
|
||||||
podAnnotations:
|
podAnnotations:
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,12 @@ explanation of `ttl` and `loop_wait` parameters.
|
||||||
automatically created by Patroni for cluster members and permanent replication
|
automatically created by Patroni for cluster members and permanent replication
|
||||||
slots. Optional.
|
slots. Optional.
|
||||||
|
|
||||||
|
* **synchronous_mode**
|
||||||
|
Patroni `synchronous_mode` parameter value. The default is set to `false`. Optional.
|
||||||
|
|
||||||
|
* **synchronous_mode_strict**
|
||||||
|
Patroni `synchronous_mode_strict` parameter value. Can be used in addition to `synchronous_mode`. The default is set to `false`. Optional.
|
||||||
|
|
||||||
## Postgres container resources
|
## Postgres container resources
|
||||||
|
|
||||||
Those parameters define [CPU and memory requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
|
Those parameters define [CPU and memory requests and limits](https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/)
|
||||||
|
|
|
||||||
|
|
@ -67,6 +67,8 @@ spec:
|
||||||
ttl: 30
|
ttl: 30
|
||||||
loop_wait: &loop_wait 10
|
loop_wait: &loop_wait 10
|
||||||
retry_timeout: 10
|
retry_timeout: 10
|
||||||
|
synchronous_mode: false
|
||||||
|
synchronous_mode_strict: false
|
||||||
maximum_lag_on_failover: 33554432
|
maximum_lag_on_failover: 33554432
|
||||||
|
|
||||||
# restore a Postgres DB with point-in-time-recovery
|
# restore a Postgres DB with point-in-time-recovery
|
||||||
|
|
|
||||||
|
|
@ -184,6 +184,10 @@ spec:
|
||||||
type: integer
|
type: integer
|
||||||
maximum_lag_on_failover:
|
maximum_lag_on_failover:
|
||||||
type: integer
|
type: integer
|
||||||
|
synchronous_mode:
|
||||||
|
type: boolean
|
||||||
|
synchronous_mode_strict:
|
||||||
|
type: boolean
|
||||||
podAnnotations:
|
podAnnotations:
|
||||||
type: object
|
type: object
|
||||||
additionalProperties:
|
additionalProperties:
|
||||||
|
|
|
||||||
|
|
@ -358,6 +358,12 @@ var PostgresCRDResourceValidation = apiextv1beta1.CustomResourceValidation{
|
||||||
"maximum_lag_on_failover": {
|
"maximum_lag_on_failover": {
|
||||||
Type: "integer",
|
Type: "integer",
|
||||||
},
|
},
|
||||||
|
"synchronous_mode": {
|
||||||
|
Type: "boolean",
|
||||||
|
},
|
||||||
|
"synchronous_mode_strict": {
|
||||||
|
Type: "boolean",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"podAnnotations": {
|
"podAnnotations": {
|
||||||
|
|
|
||||||
|
|
@ -125,6 +125,8 @@ type Patroni struct {
|
||||||
RetryTimeout uint32 `json:"retry_timeout"`
|
RetryTimeout uint32 `json:"retry_timeout"`
|
||||||
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover"` // float32 because https://github.com/kubernetes/kubernetes/issues/30213
|
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover"` // float32 because https://github.com/kubernetes/kubernetes/issues/30213
|
||||||
Slots map[string]map[string]string `json:"slots"`
|
Slots map[string]map[string]string `json:"slots"`
|
||||||
|
SynchronousMode bool `json:"synchronous_mode"`
|
||||||
|
SynchronousModeStrict bool `json:"synchronous_mode_strict"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//StandbyCluster
|
//StandbyCluster
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,8 @@ type patroniDCS struct {
|
||||||
LoopWait uint32 `json:"loop_wait,omitempty"`
|
LoopWait uint32 `json:"loop_wait,omitempty"`
|
||||||
RetryTimeout uint32 `json:"retry_timeout,omitempty"`
|
RetryTimeout uint32 `json:"retry_timeout,omitempty"`
|
||||||
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover,omitempty"`
|
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover,omitempty"`
|
||||||
|
SynchronousMode bool `json:"synchronous_mode,omitempty"`
|
||||||
|
SynchronousModeStrict bool `json:"synchronous_mode_strict,omitempty"`
|
||||||
PGBootstrapConfiguration map[string]interface{} `json:"postgresql,omitempty"`
|
PGBootstrapConfiguration map[string]interface{} `json:"postgresql,omitempty"`
|
||||||
Slots map[string]map[string]string `json:"slots,omitempty"`
|
Slots map[string]map[string]string `json:"slots,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
@ -283,6 +285,12 @@ PatroniInitDBParams:
|
||||||
if patroni.Slots != nil {
|
if patroni.Slots != nil {
|
||||||
config.Bootstrap.DCS.Slots = patroni.Slots
|
config.Bootstrap.DCS.Slots = patroni.Slots
|
||||||
}
|
}
|
||||||
|
if patroni.SynchronousMode {
|
||||||
|
config.Bootstrap.DCS.SynchronousMode = patroni.SynchronousMode
|
||||||
|
}
|
||||||
|
if patroni.SynchronousModeStrict != false {
|
||||||
|
config.Bootstrap.DCS.SynchronousModeStrict = patroni.SynchronousModeStrict
|
||||||
|
}
|
||||||
|
|
||||||
config.PgLocalConfiguration = make(map[string]interface{})
|
config.PgLocalConfiguration = make(map[string]interface{})
|
||||||
config.PgLocalConfiguration[patroniPGBinariesParameterName] = fmt.Sprintf(pgBinariesLocationTemplate, pg.PgVersion)
|
config.PgLocalConfiguration[patroniPGBinariesParameterName] = fmt.Sprintf(pgBinariesLocationTemplate, pg.PgVersion)
|
||||||
|
|
|
||||||
|
|
@ -70,11 +70,13 @@ func TestGenerateSpiloJSONConfiguration(t *testing.T) {
|
||||||
LoopWait: 10,
|
LoopWait: 10,
|
||||||
RetryTimeout: 10,
|
RetryTimeout: 10,
|
||||||
MaximumLagOnFailover: 33554432,
|
MaximumLagOnFailover: 33554432,
|
||||||
|
SynchronousMode: true,
|
||||||
|
SynchronousModeStrict: true,
|
||||||
Slots: map[string]map[string]string{"permanent_logical_1": {"type": "logical", "database": "foo", "plugin": "pgoutput"}},
|
Slots: map[string]map[string]string{"permanent_logical_1": {"type": "logical", "database": "foo", "plugin": "pgoutput"}},
|
||||||
},
|
},
|
||||||
role: "zalandos",
|
role: "zalandos",
|
||||||
opConfig: config.Config{},
|
opConfig: config.Config{},
|
||||||
result: `{"postgresql":{"bin_dir":"/usr/lib/postgresql/11/bin","pg_hba":["hostssl all all 0.0.0.0/0 md5","host all all 0.0.0.0/0 md5"]},"bootstrap":{"initdb":[{"auth-host":"md5"},{"auth-local":"trust"},"data-checksums",{"encoding":"UTF8"},{"locale":"en_US.UTF-8"}],"users":{"zalandos":{"password":"","options":["CREATEDB","NOLOGIN"]}},"dcs":{"ttl":30,"loop_wait":10,"retry_timeout":10,"maximum_lag_on_failover":33554432,"slots":{"permanent_logical_1":{"database":"foo","plugin":"pgoutput","type":"logical"}}}}}`,
|
result: `{"postgresql":{"bin_dir":"/usr/lib/postgresql/11/bin","pg_hba":["hostssl all all 0.0.0.0/0 md5","host all all 0.0.0.0/0 md5"]},"bootstrap":{"initdb":[{"auth-host":"md5"},{"auth-local":"trust"},"data-checksums",{"encoding":"UTF8"},{"locale":"en_US.UTF-8"}],"users":{"zalandos":{"password":"","options":["CREATEDB","NOLOGIN"]}},"dcs":{"ttl":30,"loop_wait":10,"retry_timeout":10,"maximum_lag_on_failover":33554432,"synchronous_mode":true,"synchronous_mode_strict":true,"slots":{"permanent_logical_1":{"database":"foo","plugin":"pgoutput","type":"logical"}}}}}`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue