Merge branch 'master' into client-go-3
This commit is contained in:
commit
f562ec8310
|
|
@ -50,8 +50,6 @@ func (c *Controller) clusterListFunc(options meta_v1.ListOptions) (runtime.Objec
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
c.queueClusterEvent(nil, pg, spec.EventSync)
|
c.queueClusterEvent(nil, pg, spec.EventSync)
|
||||||
|
|
||||||
c.logger.Debugf("Sync of the '%s' cluster has been queued", util.NameFromMeta(pg.Metadata))
|
|
||||||
activeClustersCnt++
|
activeClustersCnt++
|
||||||
}
|
}
|
||||||
if len(objList) > 0 {
|
if len(objList) > 0 {
|
||||||
|
|
@ -74,7 +72,6 @@ func (c *Controller) clusterWatchFunc(options meta_v1.ListOptions) (watch.Interf
|
||||||
RequestURI(fmt.Sprintf(constants.WatchClustersURITemplate, c.opConfig.Namespace)).
|
RequestURI(fmt.Sprintf(constants.WatchClustersURITemplate, c.opConfig.Namespace)).
|
||||||
VersionedParams(&options, api.ParameterCodec).
|
VersionedParams(&options, api.ParameterCodec).
|
||||||
FieldsSelectorParam(fields.Everything())
|
FieldsSelectorParam(fields.Everything())
|
||||||
|
|
||||||
return req.Watch()
|
return req.Watch()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,7 +113,9 @@ func (c *Controller) processEvent(obj interface{}) error {
|
||||||
c.clustersMu.Unlock()
|
c.clustersMu.Unlock()
|
||||||
|
|
||||||
if err := cl.Create(stopCh); err != nil {
|
if err := cl.Create(stopCh); err != nil {
|
||||||
logger.Errorf("could not create cluster: %s", err)
|
cl.Error = fmt.Errorf("could not create cluster: %v", err)
|
||||||
|
logger.Errorf("%v", cl.Error)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -129,7 +128,9 @@ func (c *Controller) processEvent(obj interface{}) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if err := cl.Update(event.NewSpec); err != nil {
|
if err := cl.Update(event.NewSpec); err != nil {
|
||||||
logger.Errorf("could not update cluster: %s", err)
|
cl.Error = fmt.Errorf("could not update cluster: %s", err)
|
||||||
|
logger.Errorf("%v", cl.Error)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
logger.Infof("Cluster '%s' has been updated", clusterName)
|
logger.Infof("Cluster '%s' has been updated", clusterName)
|
||||||
|
|
@ -167,7 +168,8 @@ func (c *Controller) processEvent(obj interface{}) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := cl.Sync(stopCh); err != nil {
|
if err := cl.Sync(stopCh); err != nil {
|
||||||
logger.Errorf("could not sync cluster '%s': %s", clusterName, err)
|
cl.Error = fmt.Errorf("could not sync cluster '%s': %s", clusterName, err)
|
||||||
|
logger.Errorf("%v", cl)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,8 +195,8 @@ func (c *Controller) queueClusterEvent(old, new *spec.Postgresql, eventType spec
|
||||||
if old != nil { //update, delete
|
if old != nil { //update, delete
|
||||||
uid = old.Metadata.GetUID()
|
uid = old.Metadata.GetUID()
|
||||||
clusterName = util.NameFromMeta(old.Metadata)
|
clusterName = util.NameFromMeta(old.Metadata)
|
||||||
if eventType == spec.EventUpdate && new.Error == nil && old != nil {
|
if eventType == spec.EventUpdate && new.Error == nil && old.Error != nil {
|
||||||
eventType = spec.EventAdd
|
eventType = spec.EventSync
|
||||||
clusterError = new.Error
|
clusterError = new.Error
|
||||||
} else {
|
} else {
|
||||||
clusterError = old.Error
|
clusterError = old.Error
|
||||||
|
|
@ -221,7 +223,7 @@ func (c *Controller) queueClusterEvent(old, new *spec.Postgresql, eventType spec
|
||||||
//TODO: if we delete cluster, discard all the previous events for the cluster
|
//TODO: if we delete cluster, discard all the previous events for the cluster
|
||||||
|
|
||||||
c.clusterEventQueues[workerID].Add(clusterEvent)
|
c.clusterEventQueues[workerID].Add(clusterEvent)
|
||||||
c.logger.WithField("worker", workerID).Infof("%s of the '%s' cluster has been queued for", eventType, clusterName)
|
c.logger.WithField("worker", workerID).Infof("%s of the '%s' cluster has been queued", eventType, clusterName)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Controller) postgresqlAdd(obj interface{}) {
|
func (c *Controller) postgresqlAdd(obj interface{}) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue