Minor improvements
* Set minimum number of pool instances to 2 * Improve logging of sync reasons * Improve logging of a new pool role
This commit is contained in:
parent
1c7065e4ce
commit
48cdbb6a65
|
|
@ -1240,7 +1240,7 @@ func (c *Cluster) needSyncConnPoolSpecs(oldSpec, newSpec *acidv1.ConnectionPool)
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, change := range changelog {
|
for _, change := range changelog {
|
||||||
msg := fmt.Sprintf("%s %+v from %s to %s",
|
msg := fmt.Sprintf("%s %+v from '%+v' to '%+v'",
|
||||||
change.Type, change.Path, change.From, change.To)
|
change.Type, change.Path, change.From, change.To)
|
||||||
reasons = append(reasons, msg)
|
reasons = append(reasons, msg)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2053,6 +2053,13 @@ func (c *Cluster) generateConnPoolDeployment(spec *acidv1.PostgresSpec) (
|
||||||
k8sutil.Int32ToPointer(1))
|
k8sutil.Int32ToPointer(1))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *numberOfInstances < constants.ConnPoolMinInstances {
|
||||||
|
msg := "Adjusted number of connection pool instances from %d to %d"
|
||||||
|
c.logger.Warningf(msg, numberOfInstances, constants.ConnPoolMinInstances)
|
||||||
|
|
||||||
|
*numberOfInstances = constants.ConnPoolMinInstances
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -727,7 +727,7 @@ func (c *Cluster) syncConnectionPoolWorker(oldSpec, newSpec *acidv1.Postgresql)
|
||||||
defaultsSync, defaultsReason := c.needSyncConnPoolDefaults(newConnPool, deployment)
|
defaultsSync, defaultsReason := c.needSyncConnPoolDefaults(newConnPool, deployment)
|
||||||
reason := append(specReason, defaultsReason...)
|
reason := append(specReason, defaultsReason...)
|
||||||
if specSync || defaultsSync {
|
if specSync || defaultsSync {
|
||||||
c.logger.Infof("Update connection pool deployment %s, reason: %s",
|
c.logger.Infof("Update connection pool deployment %s, reason: %+v",
|
||||||
c.connPoolName(), reason)
|
c.connPoolName(), reason)
|
||||||
|
|
||||||
newDeploymentSpec, err := c.generateConnPoolDeployment(&newSpec.Spec)
|
newDeploymentSpec, err := c.generateConnPoolDeployment(&newSpec.Spec)
|
||||||
|
|
|
||||||
|
|
@ -180,6 +180,8 @@ func (r RoleOrigin) String() string {
|
||||||
return "teams API role"
|
return "teams API role"
|
||||||
case RoleOriginSystem:
|
case RoleOriginSystem:
|
||||||
return "system role"
|
return "system role"
|
||||||
|
case RoleConnectionPool:
|
||||||
|
return "connection pool role"
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("bogus role origin value %d", r))
|
panic(fmt.Sprintf("bogus role origin value %d", r))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,4 +14,5 @@ const (
|
||||||
ConnPoolContainer = 0
|
ConnPoolContainer = 0
|
||||||
ConnPoolMaxDBConnections = 60
|
ConnPoolMaxDBConnections = 60
|
||||||
ConnPoolMaxClientConnections = 10000
|
ConnPoolMaxClientConnections = 10000
|
||||||
|
ConnPoolMinInstances = 2
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -149,22 +149,25 @@ func CoalesceInt32(val, defaultVal *int32) *int32 {
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test if any of the values is nil
|
||||||
|
func testNil(values ...*int32) bool {
|
||||||
|
for _, v := range values {
|
||||||
|
if v == nil {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// Return maximum of two integers provided via pointers. If one value is not
|
// Return maximum of two integers provided via pointers. If one value is not
|
||||||
// defined, return the other one. If both are not defined, result is also
|
// defined, return the other one. If both are not defined, result is also
|
||||||
// undefined, caller needs to check for that.
|
// undefined, caller needs to check for that.
|
||||||
func MaxInt32(a, b *int32) *int32 {
|
func MaxInt32(a, b *int32) *int32 {
|
||||||
if a == nil && b == nil {
|
if testNil(a, b) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if a == nil {
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
if b == nil {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
|
|
||||||
if *a > *b {
|
if *a > *b {
|
||||||
return a
|
return a
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue