Merge pull request #298 from zalando-incubator/fix_max_connections
Put special patroni parameters to the bootstrap.
This commit is contained in:
		
						commit
						e09e62f259
					
				|  | @ -34,6 +34,7 @@ type patroniDCS struct { | |||
| 	LoopWait                 uint32                 `json:"loop_wait,omitempty"` | ||||
| 	RetryTimeout             uint32                 `json:"retry_timeout,omitempty"` | ||||
| 	MaximumLagOnFailover     float32                `json:"maximum_lag_on_failover,omitempty"` | ||||
| 	PGBootstrapConfiguration map[string]interface{} `json:"postgresql,omitempty"` | ||||
| } | ||||
| 
 | ||||
| type pgBootstrap struct { | ||||
|  | @ -221,7 +222,22 @@ PatroniInitDBParams: | |||
| 	config.PgLocalConfiguration = make(map[string]interface{}) | ||||
| 	config.PgLocalConfiguration[patroniPGBinariesParameterName] = fmt.Sprintf(pgBinariesLocationTemplate, pg.PgVersion) | ||||
| 	if len(pg.Parameters) > 0 { | ||||
| 		config.PgLocalConfiguration[patroniPGParametersParameterName] = pg.Parameters | ||||
| 		localParameters := make(map[string]string) | ||||
| 		bootstrapParameters := make(map[string]string) | ||||
| 		for param, val := range pg.Parameters { | ||||
| 			if isBootstrapOnlyParameter(param) { | ||||
| 				bootstrapParameters[param] = val | ||||
| 			} else { | ||||
| 				localParameters[param] = val | ||||
| 			} | ||||
| 		} | ||||
| 		if len(localParameters) > 0 { | ||||
| 			config.PgLocalConfiguration[patroniPGParametersParameterName] = localParameters | ||||
| 		} | ||||
| 		if len(bootstrapParameters) > 0 { | ||||
| 			config.Bootstrap.DCS.PGBootstrapConfiguration = make(map[string]interface{}) | ||||
| 			config.Bootstrap.DCS.PGBootstrapConfiguration[patroniPGParametersParameterName] = bootstrapParameters | ||||
| 		} | ||||
| 	} | ||||
| 	config.Bootstrap.Users = map[string]pgUser{ | ||||
| 		c.OpConfig.PamRoleName: { | ||||
|  | @ -280,6 +296,19 @@ func (c *Cluster) tolerations(tolerationsSpec *[]v1.Toleration) []v1.Toleration | |||
| 	return []v1.Toleration{} | ||||
| } | ||||
| 
 | ||||
| // isBootstrapOnlyParameter checks asgainst special Patroni bootstrap parameters.
 | ||||
| // Those parameters must go to the bootstrap/dcs/postgresql/parameters section.
 | ||||
| // See http://patroni.readthedocs.io/en/latest/dynamic_configuration.html.
 | ||||
| func isBootstrapOnlyParameter(param string) bool { | ||||
| 	return param == "max_connections" || | ||||
| 		param == "max_locks_per_transaction" || | ||||
| 		param == "max_worker_processes" || | ||||
| 		param == "max_prepared_transactions" || | ||||
| 		param == "wal_level" || | ||||
| 		param == "wal_log_hints" || | ||||
| 		param == "track_commit_timestamp" | ||||
| } | ||||
| 
 | ||||
| func (c *Cluster) generatePodTemplate( | ||||
| 	uid types.UID, | ||||
| 	resourceRequirements *v1.ResourceRequirements, | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue