Delete if a new specification is nil

Use coalesce for username too.
This commit is contained in:
Dmitrii Dolgov 2020-02-17 15:34:10 +01:00
parent 35d82e5a17
commit 97217e27ed
2 changed files with 11 additions and 4 deletions

View File

@ -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,

View File

@ -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 ||