Skip to content

Commit

Permalink
Fix a crash when creating new databases.
Browse files Browse the repository at this point in the history
Open the database connection before calling create database.
  • Loading branch information
alexeyklyukin committed Nov 2, 2017
1 parent fc6508b commit aef5d69
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/cluster/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,20 @@ func (c *Cluster) GetPodDisruptionBudget() *policybeta1.PodDisruptionBudget {

func (c *Cluster) createDatabases() error {
c.setProcessName("creating databases")

if len(c.Spec.Databases) == 0 {
return nil
}

if err := c.initDbConn(); err != nil {
return fmt.Errorf("could not init database connection")
}
defer func() {
if err := c.closeDbConn(); err != nil {
c.logger.Errorf("could not close database connection: %v", err)
}
}()

for datname, owner := range c.Spec.Databases {
if err := c.executeCreateDatabase(datname, owner); err != nil {
return err
Expand Down

0 comments on commit aef5d69

Please sign in to comment.