Fix uninitialized ConnectionPool structure usage

It's being used quite early to setup a connection pool user, and if only
enableConnectionPool specified, can be nil.
This commit is contained in:
Dmitrii Dolgov 2020-02-14 13:04:24 +01:00
parent 447a659d6d
commit 0095be0279
1 changed files with 5 additions and 0 deletions

View File

@ -863,6 +863,11 @@ func (c *Cluster) initSystemUsers() {
// created by operator as a normal pgUser
if c.needConnectionPool() {
// initialize empty connection pool if not done yet
if c.Spec.ConnectionPool == nil {
c.Spec.ConnectionPool = &acidv1.ConnectionPool{}
}
username := c.Spec.ConnectionPool.User
if username == "" {
username = c.OpConfig.ConnectionPool.User