Delete if a new specification is nil
Use coalesce for username too.
This commit is contained in:
parent
35d82e5a17
commit
97217e27ed
|
|
@ -868,10 +868,9 @@ func (c *Cluster) initSystemUsers() {
|
|||
c.Spec.ConnectionPool = &acidv1.ConnectionPool{}
|
||||
}
|
||||
|
||||
username := c.Spec.ConnectionPool.User
|
||||
if username == "" {
|
||||
username = c.OpConfig.ConnectionPool.User
|
||||
}
|
||||
username := util.Coalesce(
|
||||
c.Spec.ConnectionPool.User,
|
||||
c.OpConfig.ConnectionPool.User)
|
||||
|
||||
c.systemUsers[constants.ConnectionPoolUserKeyName] = spec.PgUser{
|
||||
Origin: spec.RoleConnectionPool,
|
||||
|
|
|
|||
|
|
@ -115,6 +115,14 @@ func (c *Cluster) Sync(newSpec *acidv1.Postgresql) error {
|
|||
oldPool := oldSpec.Spec.ConnectionPool
|
||||
newPool := newSpec.Spec.ConnectionPool
|
||||
|
||||
if newPool == nil {
|
||||
// previously specified connectionPool was removed, so delete
|
||||
// connection pool
|
||||
if err := c.deleteConnectionPool(); err != nil {
|
||||
c.logger.Warningf("could not remove connection pool: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// do sync in case if any resources were not remembered (it means they
|
||||
// probably were not created, or if specification differs
|
||||
if c.ConnectionPool == nil ||
|
||||
|
|
|
|||
Loading…
Reference in New Issue