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:
Oleksii Kliukin
2017-08-10 10:10:00 +02:00
committed by GitHub
parent 8b58782a4a
commit f15f93f479
4 changed files with 45 additions and 38 deletions
+2 -5
View File
@@ -415,10 +415,7 @@ func (c *Cluster) deleteSecret(secret *v1.Secret) error {
return err
}
func (c *Cluster) createUsers() (err error) {
func (c *Cluster) createRoles() (err error) {
// TODO: figure out what to do with duplicate names (humans and robots) among pgUsers
reqs := c.userSyncStrategy.ProduceSyncRequests(nil, c.pgUsers)
err = c.userSyncStrategy.ExecuteSyncRequests(reqs, c.pgDb)
return err
return c.syncRoles(false)
}