mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-18 06:38:55 +02:00
Bugfix/close db connections (#78)
Open and close DB connections on-demand. Previously, we used to leave the DB connection open while the cluster was registered with the operator, potentially resutling in dangled connections if the operator terminates abnormally. Small refactoring around the role syncing code.
This commit is contained in:
@@ -143,6 +143,7 @@ func (c *Cluster) setStatus(status spec.PostgresStatus) {
|
||||
}
|
||||
}
|
||||
|
||||
// initUsers populates c.systemUsers and c.pgUsers maps.
|
||||
func (c *Cluster) initUsers() error {
|
||||
c.initSystemUsers()
|
||||
|
||||
@@ -204,7 +205,7 @@ func (c *Cluster) Create() error {
|
||||
if err = c.initUsers(); err != nil {
|
||||
return err
|
||||
}
|
||||
c.logger.Infof("User secrets have been initialized")
|
||||
c.logger.Infof("Users have been initialized")
|
||||
|
||||
if err = c.applySecrets(); err != nil {
|
||||
return fmt.Errorf("could not create secrets: %v", err)
|
||||
@@ -226,11 +227,7 @@ func (c *Cluster) Create() error {
|
||||
c.logger.Infof("pods are ready")
|
||||
|
||||
if !(c.masterLess || c.databaseAccessDisabled()) {
|
||||
err = c.initDbConn()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not init db connection: %v", err)
|
||||
}
|
||||
err = c.createUsers()
|
||||
err = c.createRoles()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create users: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user