diff --git a/pkg/cluster/cluster.go b/pkg/cluster/cluster.go index 4f2fe4efb..1328646ac 100644 --- a/pkg/cluster/cluster.go +++ b/pkg/cluster/cluster.go @@ -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, diff --git a/pkg/cluster/sync.go b/pkg/cluster/sync.go index 47c8c01d6..bd4a7fc28 100644 --- a/pkg/cluster/sync.go +++ b/pkg/cluster/sync.go @@ -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 ||