Skip to content

Commit f5550c3

Browse files
committed
Put special patroni parameters to the bootstrap.
Some special patroni postgresql parameters, like max_connections, should reside in the bootstrap.dcs.postgresql.parameters section to come into effect.
1 parent e6d12b3 commit f5550c3

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

pkg/cluster/k8sres.go

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ type pgUser struct {
3030
}
3131

3232
type patroniDCS struct {
33-
TTL uint32 `json:"ttl,omitempty"`
34-
LoopWait uint32 `json:"loop_wait,omitempty"`
35-
RetryTimeout uint32 `json:"retry_timeout,omitempty"`
36-
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover,omitempty"`
33+
TTL uint32 `json:"ttl,omitempty"`
34+
LoopWait uint32 `json:"loop_wait,omitempty"`
35+
RetryTimeout uint32 `json:"retry_timeout,omitempty"`
36+
MaximumLagOnFailover float32 `json:"maximum_lag_on_failover,omitempty"`
37+
PGBootstrapConfiguration map[string]interface{} `json:"postgresql,omitempty"`
3738
}
3839

3940
type pgBootstrap struct {
@@ -221,7 +222,22 @@ PatroniInitDBParams:
221222
config.PgLocalConfiguration = make(map[string]interface{})
222223
config.PgLocalConfiguration[patroniPGBinariesParameterName] = fmt.Sprintf(pgBinariesLocationTemplate, pg.PgVersion)
223224
if len(pg.Parameters) > 0 {
224-
config.PgLocalConfiguration[patroniPGParametersParameterName] = pg.Parameters
225+
localParameters := make(map[string]string)
226+
bootstrapParameters := make(map[string]string)
227+
for param, val := range pg.Parameters {
228+
if !isBootstrapOnlyParameter(param) {
229+
localParameters[param] = val
230+
} else {
231+
bootstrapParameters[param] = val
232+
}
233+
}
234+
if len(localParameters) > 0 {
235+
config.PgLocalConfiguration[patroniPGParametersParameterName] = localParameters
236+
}
237+
if len(bootstrapParameters) > 0 {
238+
config.Bootstrap.DCS.PGBootstrapConfiguration = make(map[string]interface{})
239+
config.Bootstrap.DCS.PGBootstrapConfiguration[patroniPGParametersParameterName] = bootstrapParameters
240+
}
225241
}
226242
config.Bootstrap.Users = map[string]pgUser{
227243
c.OpConfig.PamRoleName: {
@@ -280,6 +296,16 @@ func (c *Cluster) tolerations(tolerationsSpec *[]v1.Toleration) []v1.Toleration
280296
return []v1.Toleration{}
281297
}
282298

299+
func isBootstrapOnlyParameter(param string) bool {
300+
return param == "max_connections" ||
301+
param == "max_locks_per_transaction" ||
302+
param == "max_worker_processes" ||
303+
param == "max_prepared_transactions" ||
304+
param == "wal_level" ||
305+
param == "wal_log_hints" ||
306+
param == "track_commit_timestamp"
307+
}
308+
283309
func (c *Cluster) generatePodTemplate(
284310
uid types.UID,
285311
resourceRequirements *v1.ResourceRequirements,

0 commit comments

Comments
 (0)