create key in the cluster map on cluster creation failure

This commit is contained in:
Murat Kabilov 2017-04-10 14:30:08 +02:00
parent 3b99ce3d2e
commit ce90a54cf9
1 changed files with 3 additions and 2 deletions

View File

@ -96,6 +96,9 @@ func (c *Controller) postgresqlAdd(obj interface{}) {
c.logger.Infof("Creation of a new Postgresql cluster '%s' started", clusterName)
cl := cluster.New(c.makeClusterConfig(), *pg, c.logger.Logger)
c.clusters[clusterName] = cl
cl.SetStatus(spec.ClusterStatusCreating)
if err := cl.Create(); err != nil {
c.logger.Errorf("Can't create cluster: %s", err)
@ -103,10 +106,8 @@ func (c *Controller) postgresqlAdd(obj interface{}) {
return
}
cl.SetStatus(spec.ClusterStatusRunning) //TODO: are you sure it's running?
stopCh := make(chan struct{})
c.stopChMap[clusterName] = stopCh
c.clusters[clusterName] = cl
go cl.Run(stopCh)
c.logger.Infof("Postgresql cluster '%s' has been created", clusterName)