mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-06 01:02:16 +02:00
Add possibility to set max db connections
Since it's an important part of a connection pool configuration, allow to configure max db connections, that pool will open to a target db. From this numbers several others (like default pool size, min pool size, reserve) will be deduced, taking into account desired number of instances.
This commit is contained in:
@@ -22,6 +22,10 @@ func (c *Controller) readOperatorConfigurationFromCRD(configObjectNamespace, con
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func int32ToPointer(value int32) *int32 {
|
||||
return &value
|
||||
}
|
||||
|
||||
// importConfigurationFromCRD is a transitional function that converts CRD configuration to the one based on the configmap
|
||||
func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigurationData) *config.Config {
|
||||
result := &config.Config{}
|
||||
@@ -146,14 +150,13 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||
|
||||
// Connection pool. Looks like we can't use defaulting in CRD before 1.17,
|
||||
// so ensure default values here.
|
||||
result.ConnectionPool.NumberOfInstances = fromCRD.ConnectionPool.NumberOfInstances
|
||||
if result.ConnectionPool.NumberOfInstances == nil ||
|
||||
*result.ConnectionPool.NumberOfInstances < 1 {
|
||||
var value int32
|
||||
result.ConnectionPool.NumberOfInstances = util.CoalesceInt32(
|
||||
fromCRD.ConnectionPool.NumberOfInstances,
|
||||
int32ToPointer(1))
|
||||
|
||||
value = 1
|
||||
result.ConnectionPool.NumberOfInstances = &value
|
||||
}
|
||||
result.ConnectionPool.NumberOfInstances = util.MaxInt32(
|
||||
result.ConnectionPool.NumberOfInstances,
|
||||
int32ToPointer(1))
|
||||
|
||||
result.ConnectionPool.Schema = util.Coalesce(
|
||||
fromCRD.ConnectionPool.Schema,
|
||||
@@ -187,5 +190,9 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur
|
||||
fromCRD.ConnectionPool.DefaultMemoryLimit,
|
||||
constants.ConnectionPoolDefaultMemoryLimit)
|
||||
|
||||
result.ConnectionPool.MaxDBConnections = util.CoalesceInt32(
|
||||
fromCRD.ConnectionPool.MaxDBConnections,
|
||||
int32ToPointer(constants.ConnPoolMaxDBConnections))
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user