use neutral name for set cluster status function

This commit is contained in:
Murat Kabilov 2017-03-08 16:15:41 +01:00
parent 1c6e7ac2e7
commit 486c8ecb07
2 changed files with 7 additions and 7 deletions

View File

@ -107,7 +107,7 @@ func (c *Cluster) needsRollingUpdate(otherSpec *spec.Postgresql) bool {
return false return false
} }
func (c *Cluster) MustSetStatus(status spec.PostgresStatus) { func (c *Cluster) SetStatus(status spec.PostgresStatus) {
b, err := json.Marshal(status) b, err := json.Marshal(status)
if err != nil { if err != nil {
c.logger.Fatalf("Can't marshal status: %s", err) c.logger.Fatalf("Can't marshal status: %s", err)

View File

@ -94,13 +94,13 @@ func (c *Controller) postgresqlAdd(obj interface{}) {
c.logger.Infof("Creation of a new Postgresql cluster '%s' started", clusterName) c.logger.Infof("Creation of a new Postgresql cluster '%s' started", clusterName)
cl := cluster.New(c.makeClusterConfig(), *pg) cl := cluster.New(c.makeClusterConfig(), *pg)
cl.MustSetStatus(spec.ClusterStatusCreating) cl.SetStatus(spec.ClusterStatusCreating)
if err := cl.Create(); err != nil { if err := cl.Create(); err != nil {
c.logger.Errorf("Can't create cluster: %s", err) c.logger.Errorf("Can't create cluster: %s", err)
cl.MustSetStatus(spec.ClusterStatusAddFailed) cl.SetStatus(spec.ClusterStatusAddFailed)
return return
} }
cl.MustSetStatus(spec.ClusterStatusRunning) //TODO: are you sure it's running? cl.SetStatus(spec.ClusterStatusRunning) //TODO: are you sure it's running?
stopCh := make(chan struct{}) stopCh := make(chan struct{})
c.stopChMap[clusterName] = stopCh c.stopChMap[clusterName] = stopCh
@ -137,14 +137,14 @@ func (c *Controller) postgresqlUpdate(prev, cur interface{}) {
return return
} }
pgCluster.MustSetStatus(spec.ClusterStatusUpdating) pgCluster.SetStatus(spec.ClusterStatusUpdating)
if err := pgCluster.Update(pgNew); err != nil { if err := pgCluster.Update(pgNew); err != nil {
pgCluster.MustSetStatus(spec.ClusterStatusUpdateFailed) pgCluster.SetStatus(spec.ClusterStatusUpdateFailed)
c.logger.Errorf("Can't update cluster: %s", err) c.logger.Errorf("Can't update cluster: %s", err)
} else { } else {
c.logger.Infof("Cluster has been updated") c.logger.Infof("Cluster has been updated")
} }
pgCluster.MustSetStatus(spec.ClusterStatusRunning) pgCluster.SetStatus(spec.ClusterStatusRunning)
} }
func (c *Controller) postgresqlDelete(obj interface{}) { func (c *Controller) postgresqlDelete(obj interface{}) {