func (c *Cluster) Run() {

	reconcileTicker := time.NewTicker(c.reconcileInterval)
	defer reconcileTicker.Stop()

	statusSyncTicker := time.NewTicker(c.statusReconcileInterval)
	defer statusSyncTicker.Stop()

	metrics.ClustersTotal.Inc()
	klog.Infof("run control process for etcd %s/%s", c.etcd.Namespace, c.etcd.Name)

	for {
		select {
		case <-c.stopCh:
			return
		case <-reconcileTicker.C:
			klog.Infof("start sync etcd %s/%s", c.etcd.Namespace, c.etcd.Name)
			metrics.EtcdSyncTotal.Inc()
			if err := c.sync(); err != nil {
				metrics.EtcdSyncFailedTotal.WithLabelValues(err.Error()).Inc()
				klog.Errorf("Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
				c.recorder.Eventf(c.etcd, corev1.EventTypeWarning, "Sync Etcd Failed", "Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
			} else {
				metrics.EtcdSyncSucceedTotal.Inc()
			}
		case <-statusSyncTicker.C:
			if err := c.syncStatus(); err != nil {
				klog.Error(err)
			}
		case <-c.eventCh:
			func() {
				klog.Infof("start sync etcd %s/%s", c.etcd.Namespace, c.etcd.Name)
				metrics.EtcdSyncTotal.Inc()
				if err := c.sync(); err != nil {
					metrics.EtcdSyncFailedTotal.WithLabelValues(err.Error()).Inc()
					klog.Errorf("Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
					c.recorder.Eventf(c.etcd, corev1.EventTypeWarning, "Sync Etcd Failed", "Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
				} else {
					metrics.EtcdSyncSucceedTotal.Inc()
				}
			}()
		}

		time.Sleep(time.Second * 2) // slow down
	}

}
// Run runs the Cluster controller.
Run runs the Cluster controller.
// Run runs the Cluster controller .
func (c *Cluster) Run() {
	reconcileTicker := time.NewTicker(c.reconcileInterval)
	defer reconcileTicker.Stop()
	statusSyncTicker := time.NewTicker(c.statusReconcileInterval)
	defer statusSyncTicker.Stop()
	metrics.ClustersTotal.Inc()
	klog.Infof("run control process for etcd %s/%s", c.etcd.Namespace, c.etcd.Name)
	for {
		select {
		case <-c.stopCh:
			return
		case <-reconcileTicker.C:
			klog.Infof("start sync etcd %s/%s", c.etcd.Namespace, c.etcd.Name)
			metrics.EtcdSyncTotal.Inc()
			if err := c.sync(); err != nil {
				metrics.EtcdSyncFailedTotal.WithLabelValues(err.Error()).Inc()
				klog.Errorf("Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
				c.recorder.Eventf(c.etcd, corev1.EventTypeWarning, "Sync Etcd Failed", "Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
			} else {
				metrics.EtcdSyncSucceedTotal.Inc()
			}
		case <-statusSyncTicker.C:
			if err := c.syncStatus(); err != nil {
				klog.Error(err)
			}
		case <-c.eventCh:
			func() {
				klog.Infof("start sync etcd %s/%s", c.etcd.Namespace, c.etcd.Name)
				metrics.EtcdSyncTotal.Inc()
				if err := c.sync(); err != nil {
					metrics.EtcdSyncFailedTotal.WithLabelValues(err.Error()).Inc()
					klog.Errorf("Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
					c.recorder.Eventf(c.etcd, corev1.EventTypeWarning, "Sync Etcd Failed", "Sync etcd %s/%s failed, err: %s", c.etcd.Namespace, c.etcd.Name, err)
				} else {
					metrics.EtcdSyncSucceedTotal.Inc()
				}
			}()
		}
		time.Sleep(time.Second * 2) 
	}
}
func ( c * Cluster ) Run ( ) { reconcileTicker := time . NewTicker ( c . reconcileInterval ) defer reconcileTicker . Stop ( ) statusSyncTicker := time . NewTicker ( c . statusReconcileInterval ) defer statusSyncTicker . Stop ( ) metrics . ClustersTotal . Inc ( ) klog . Infof ( " " , c . etcd . Namespace , c . etcd . Name ) for { select { case <- c . stopCh : return case <- reconcileTicker . C : klog . Infof ( " " , c . etcd . Namespace , c . etcd . Name ) metrics . EtcdSyncTotal . Inc ( ) if err := c . sync ( ) ; err != nil { metrics . EtcdSyncFailedTotal . WithLabelValues ( err . Error ( ) ) . Inc ( ) klog . Errorf ( " " , c . etcd . Namespace , c . etcd . Name , err ) c . recorder . Eventf ( c . etcd , corev1 . EventTypeWarning , " " , " " , c . etcd . Namespace , c . etcd . Name , err ) } else { metrics . EtcdSyncSucceedTotal . Inc ( ) } case <- statusSyncTicker . C : if err := c . syncStatus ( ) ; err != nil { klog . Error ( err ) } case <- c . eventCh : func ( ) { klog . Infof ( " " , c . etcd . Namespace , c . etcd . Name ) metrics . EtcdSyncTotal . Inc ( ) if err := c . sync ( ) ; err != nil { metrics . EtcdSyncFailedTotal . WithLabelValues ( err . Error ( ) ) . Inc ( ) klog . Errorf ( " " , c . etcd . Namespace , c . etcd . Name , err ) c . recorder . Eventf ( c . etcd , corev1 . EventTypeWarning , " " , " " , c . etcd . Namespace , c . etcd . Name , err ) } else { metrics . EtcdSyncSucceedTotal . Inc ( ) } } ( ) } time . Sleep ( time . Second * 2 ) } }
Run runs the Cluster controller.
Run runs the Cluster controller .
// slow down