func NewController(
	kubeCli kubernetes.Interface,
	cli versioned.Interface,
	genericCli client.Client,
	informerFactory informers.SharedInformerFactory,
	kubeInformerFactory kubeinformers.SharedInformerFactory,
	autoFailover bool,
	pdFailoverPeriod time.Duration,
	tikvFailoverPeriod time.Duration,
) *Controller {
	eventBroadcaster := record.NewBroadcasterWithCorrelatorOptions(record.CorrelatorOptions{QPS: 1})
	eventBroadcaster.StartLogging(klog.V(2).Infof)
	eventBroadcaster.StartRecordingToSink(&eventv1.EventSinkImpl{
		Interface: eventv1.New(kubeCli.CoreV1().RESTClient()).Events("")})
	recorder := eventBroadcaster.NewRecorder(v1alpha1.Scheme, corev1.EventSource{Component: "tikv-controller-manager"})

	tcInformer := informerFactory.Tikv().V1alpha1().TikvClusters()
	setInformer := kubeInformerFactory.Apps().V1().StatefulSets()
	svcInformer := kubeInformerFactory.Core().V1().Services()
	epsInformer := kubeInformerFactory.Core().V1().Endpoints()
	pvcInformer := kubeInformerFactory.Core().V1().PersistentVolumeClaims()
	pvInformer := kubeInformerFactory.Core().V1().PersistentVolumes()
	podInformer := kubeInformerFactory.Core().V1().Pods()
	nodeInformer := kubeInformerFactory.Core().V1().Nodes()

	tcControl := controller.NewRealTikvClusterControl(cli, tcInformer.Lister(), recorder)
	pdControl := pdapi.NewDefaultPDControl(kubeCli)
	setControl := controller.NewRealStatefuSetControl(kubeCli, setInformer.Lister(), recorder)
	svcControl := controller.NewRealServiceControl(kubeCli, svcInformer.Lister(), recorder)
	pvControl := controller.NewRealPVControl(kubeCli, pvcInformer.Lister(), pvInformer.Lister(), recorder)
	pvcControl := controller.NewRealPVCControl(kubeCli, recorder, pvcInformer.Lister())
	podControl := controller.NewRealPodControl(kubeCli, pdControl, podInformer.Lister(), recorder)
	typedControl := controller.NewTypedControl(controller.NewRealGenericControl(genericCli, recorder))
	pdScaler := mm.NewPDScaler(pdControl, pvcInformer.Lister(), pvcControl)
	tikvScaler := mm.NewTiKVScaler(pdControl, pvcInformer.Lister(), pvcControl, podInformer.Lister())
	pdFailover := mm.NewPDFailover(cli, pdControl, pdFailoverPeriod, podInformer.Lister(), podControl, pvcInformer.Lister(), pvcControl, pvInformer.Lister(), recorder)
	tikvFailover := mm.NewTiKVFailover(tikvFailoverPeriod, recorder)
	pdUpgrader := mm.NewPDUpgrader(pdControl, podControl, podInformer.Lister())
	tikvUpgrader := mm.NewTiKVUpgrader(pdControl, podControl, podInformer.Lister())

	tcc := &Controller{
		kubeClient: kubeCli,
		cli:        cli,
		control: NewDefaultTikvClusterControl(
			tcControl,
			mm.NewPDMemberManager(
				pdControl,
				setControl,
				svcControl,
				podControl,
				typedControl,
				setInformer.Lister(),
				svcInformer.Lister(),
				podInformer.Lister(),
				epsInformer.Lister(),
				pvcInformer.Lister(),
				pdScaler,
				pdUpgrader,
				autoFailover,
				pdFailover,
			),
			mm.NewTiKVMemberManager(
				pdControl,
				setControl,
				svcControl,
				typedControl,
				setInformer.Lister(),
				svcInformer.Lister(),
				podInformer.Lister(),
				nodeInformer.Lister(),
				autoFailover,
				tikvFailover,
				tikvScaler,
				tikvUpgrader,
			),
			meta.NewMetaManager(
				pvcInformer.Lister(),
				pvcControl,
				pvInformer.Lister(),
				pvControl,
				podInformer.Lister(),
				podControl,
			),
			mm.NewOrphanPodsCleaner(
				podInformer.Lister(),
				podControl,
				pvcInformer.Lister(),
				kubeCli,
			),
			mm.NewPDDiscoveryManager(typedControl),
			&tikvClusterConditionUpdater{},
			recorder,
		),
		queue: workqueue.NewNamedRateLimitingQueue(
			workqueue.DefaultControllerRateLimiter(),
			"tikvcluster",
		),
	}

	tcInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: tcc.enqueueTikvCluster,
		UpdateFunc: func(old, cur interface{}) {
			tcc.enqueueTikvCluster(cur)
		},
		DeleteFunc: tcc.enqueueTikvCluster,
	})
	tcc.tcLister = tcInformer.Lister()
	tcc.tcListerSynced = tcInformer.Informer().HasSynced

	setInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: tcc.addStatefulSet,
		UpdateFunc: func(old, cur interface{}) {
			tcc.updateStatefuSet(old, cur)
		},
		DeleteFunc: tcc.deleteStatefulSet,
	})
	tcc.setLister = setInformer.Lister()
	tcc.setListerSynced = setInformer.Informer().HasSynced

	return tcc
}
// NewController creates a tikvcluster controller.
NewController creates a tikvcluster controller.
// NewController creates a tikvcluster controller .
func NewController(
	kubeCli kubernetes.Interface,
	cli versioned.Interface,
	genericCli client.Client,
	informerFactory informers.SharedInformerFactory,
	kubeInformerFactory kubeinformers.SharedInformerFactory,
	autoFailover bool,
	pdFailoverPeriod time.Duration,
	tikvFailoverPeriod time.Duration,
) *Controller {
	eventBroadcaster := record.NewBroadcasterWithCorrelatorOptions(record.CorrelatorOptions{QPS: 1})
	eventBroadcaster.StartLogging(klog.V(2).Infof)
	eventBroadcaster.StartRecordingToSink(&eventv1.EventSinkImpl{
		Interface: eventv1.New(kubeCli.CoreV1().RESTClient()).Events("")})
	recorder := eventBroadcaster.NewRecorder(v1alpha1.Scheme, corev1.EventSource{Component: "tikv-controller-manager"})
	tcInformer := informerFactory.Tikv().V1alpha1().TikvClusters()
	setInformer := kubeInformerFactory.Apps().V1().StatefulSets()
	svcInformer := kubeInformerFactory.Core().V1().Services()
	epsInformer := kubeInformerFactory.Core().V1().Endpoints()
	pvcInformer := kubeInformerFactory.Core().V1().PersistentVolumeClaims()
	pvInformer := kubeInformerFactory.Core().V1().PersistentVolumes()
	podInformer := kubeInformerFactory.Core().V1().Pods()
	nodeInformer := kubeInformerFactory.Core().V1().Nodes()
	tcControl := controller.NewRealTikvClusterControl(cli, tcInformer.Lister(), recorder)
	pdControl := pdapi.NewDefaultPDControl(kubeCli)
	setControl := controller.NewRealStatefuSetControl(kubeCli, setInformer.Lister(), recorder)
	svcControl := controller.NewRealServiceControl(kubeCli, svcInformer.Lister(), recorder)
	pvControl := controller.NewRealPVControl(kubeCli, pvcInformer.Lister(), pvInformer.Lister(), recorder)
	pvcControl := controller.NewRealPVCControl(kubeCli, recorder, pvcInformer.Lister())
	podControl := controller.NewRealPodControl(kubeCli, pdControl, podInformer.Lister(), recorder)
	typedControl := controller.NewTypedControl(controller.NewRealGenericControl(genericCli, recorder))
	pdScaler := mm.NewPDScaler(pdControl, pvcInformer.Lister(), pvcControl)
	tikvScaler := mm.NewTiKVScaler(pdControl, pvcInformer.Lister(), pvcControl, podInformer.Lister())
	pdFailover := mm.NewPDFailover(cli, pdControl, pdFailoverPeriod, podInformer.Lister(), podControl, pvcInformer.Lister(), pvcControl, pvInformer.Lister(), recorder)
	tikvFailover := mm.NewTiKVFailover(tikvFailoverPeriod, recorder)
	pdUpgrader := mm.NewPDUpgrader(pdControl, podControl, podInformer.Lister())
	tikvUpgrader := mm.NewTiKVUpgrader(pdControl, podControl, podInformer.Lister())
	tcc := &Controller{
		kubeClient: kubeCli,
		cli:        cli,
		control: NewDefaultTikvClusterControl(
			tcControl,
			mm.NewPDMemberManager(
				pdControl,
				setControl,
				svcControl,
				podControl,
				typedControl,
				setInformer.Lister(),
				svcInformer.Lister(),
				podInformer.Lister(),
				epsInformer.Lister(),
				pvcInformer.Lister(),
				pdScaler,
				pdUpgrader,
				autoFailover,
				pdFailover,
			),
			mm.NewTiKVMemberManager(
				pdControl,
				setControl,
				svcControl,
				typedControl,
				setInformer.Lister(),
				svcInformer.Lister(),
				podInformer.Lister(),
				nodeInformer.Lister(),
				autoFailover,
				tikvFailover,
				tikvScaler,
				tikvUpgrader,
			),
			meta.NewMetaManager(
				pvcInformer.Lister(),
				pvcControl,
				pvInformer.Lister(),
				pvControl,
				podInformer.Lister(),
				podControl,
			),
			mm.NewOrphanPodsCleaner(
				podInformer.Lister(),
				podControl,
				pvcInformer.Lister(),
				kubeCli,
			),
			mm.NewPDDiscoveryManager(typedControl),
			&tikvClusterConditionUpdater{},
			recorder,
		),
		queue: workqueue.NewNamedRateLimitingQueue(
			workqueue.DefaultControllerRateLimiter(),
			"tikvcluster",
		),
	}
	tcInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: tcc.enqueueTikvCluster,
		UpdateFunc: func(old, cur interface{}) {
			tcc.enqueueTikvCluster(cur)
		},
		DeleteFunc: tcc.enqueueTikvCluster,
	})
	tcc.tcLister = tcInformer.Lister()
	tcc.tcListerSynced = tcInformer.Informer().HasSynced
	setInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc: tcc.addStatefulSet,
		UpdateFunc: func(old, cur interface{}) {
			tcc.updateStatefuSet(old, cur)
		},
		DeleteFunc: tcc.deleteStatefulSet,
	})
	tcc.setLister = setInformer.Lister()
	tcc.setListerSynced = setInformer.Informer().HasSynced
	return tcc
}
func NewController ( kubeCli kubernetes . Interface , cli versioned . Interface , genericCli client . Client , informerFactory informers . SharedInformerFactory , kubeInformerFactory kubeinformers . SharedInformerFactory , autoFailover bool , pdFailoverPeriod time . Duration , tikvFailoverPeriod time . Duration , ) * Controller { eventBroadcaster := record . NewBroadcasterWithCorrelatorOptions ( record . CorrelatorOptions { QPS : 1 } ) eventBroadcaster . StartLogging ( klog . V ( 2 ) . Infof ) eventBroadcaster . StartRecordingToSink ( & eventv1 . EventSinkImpl { Interface : eventv1 . New ( kubeCli . CoreV1 ( ) . RESTClient ( ) ) . Events ( " " ) } ) recorder := eventBroadcaster . NewRecorder ( v1alpha1 . Scheme , corev1 . EventSource { Component : " " } ) tcInformer := informerFactory . Tikv ( ) . V1alpha1 ( ) . TikvClusters ( ) setInformer := kubeInformerFactory . Apps ( ) . V1 ( ) . StatefulSets ( ) svcInformer := kubeInformerFactory . Core ( ) . V1 ( ) . Services ( ) epsInformer := kubeInformerFactory . Core ( ) . V1 ( ) . Endpoints ( ) pvcInformer := kubeInformerFactory . Core ( ) . V1 ( ) . PersistentVolumeClaims ( ) pvInformer := kubeInformerFactory . Core ( ) . V1 ( ) . PersistentVolumes ( ) podInformer := kubeInformerFactory . Core ( ) . V1 ( ) . Pods ( ) nodeInformer := kubeInformerFactory . Core ( ) . V1 ( ) . Nodes ( ) tcControl := controller . NewRealTikvClusterControl ( cli , tcInformer . Lister ( ) , recorder ) pdControl := pdapi . NewDefaultPDControl ( kubeCli ) setControl := controller . NewRealStatefuSetControl ( kubeCli , setInformer . Lister ( ) , recorder ) svcControl := controller . NewRealServiceControl ( kubeCli , svcInformer . Lister ( ) , recorder ) pvControl := controller . NewRealPVControl ( kubeCli , pvcInformer . Lister ( ) , pvInformer . Lister ( ) , recorder ) pvcControl := controller . NewRealPVCControl ( kubeCli , recorder , pvcInformer . Lister ( ) ) podControl := controller . NewRealPodControl ( kubeCli , pdControl , podInformer . Lister ( ) , recorder ) typedControl := controller . NewTypedControl ( controller . NewRealGenericControl ( genericCli , recorder ) ) pdScaler := mm . NewPDScaler ( pdControl , pvcInformer . Lister ( ) , pvcControl ) tikvScaler := mm . NewTiKVScaler ( pdControl , pvcInformer . Lister ( ) , pvcControl , podInformer . Lister ( ) ) pdFailover := mm . NewPDFailover ( cli , pdControl , pdFailoverPeriod , podInformer . Lister ( ) , podControl , pvcInformer . Lister ( ) , pvcControl , pvInformer . Lister ( ) , recorder ) tikvFailover := mm . NewTiKVFailover ( tikvFailoverPeriod , recorder ) pdUpgrader := mm . NewPDUpgrader ( pdControl , podControl , podInformer . Lister ( ) ) tikvUpgrader := mm . NewTiKVUpgrader ( pdControl , podControl , podInformer . Lister ( ) ) tcc := & Controller { kubeClient : kubeCli , cli : cli , control : NewDefaultTikvClusterControl ( tcControl , mm . NewPDMemberManager ( pdControl , setControl , svcControl , podControl , typedControl , setInformer . Lister ( ) , svcInformer . Lister ( ) , podInformer . Lister ( ) , epsInformer . Lister ( ) , pvcInformer . Lister ( ) , pdScaler , pdUpgrader , autoFailover , pdFailover , ) , mm . NewTiKVMemberManager ( pdControl , setControl , svcControl , typedControl , setInformer . Lister ( ) , svcInformer . Lister ( ) , podInformer . Lister ( ) , nodeInformer . Lister ( ) , autoFailover , tikvFailover , tikvScaler , tikvUpgrader , ) , meta . NewMetaManager ( pvcInformer . Lister ( ) , pvcControl , pvInformer . Lister ( ) , pvControl , podInformer . Lister ( ) , podControl , ) , mm . NewOrphanPodsCleaner ( podInformer . Lister ( ) , podControl , pvcInformer . Lister ( ) , kubeCli , ) , mm . NewPDDiscoveryManager ( typedControl ) , & tikvClusterConditionUpdater { } , recorder , ) , queue : workqueue . NewNamedRateLimitingQueue ( workqueue . DefaultControllerRateLimiter ( ) , " " , ) , } tcInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : tcc . enqueueTikvCluster , UpdateFunc : func ( old , cur interface { } ) { tcc . enqueueTikvCluster ( cur ) } , DeleteFunc : tcc . enqueueTikvCluster , } ) tcc . tcLister = tcInformer . Lister ( ) tcc . tcListerSynced = tcInformer . Informer ( ) . HasSynced setInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : tcc . addStatefulSet , UpdateFunc : func ( old , cur interface { } ) { tcc . updateStatefuSet ( old , cur ) } , DeleteFunc : tcc . deleteStatefulSet , } ) tcc . setLister = setInformer . Lister ( ) tcc . setListerSynced = setInformer . Informer ( ) . HasSynced return tcc }
NewController creates a tikvcluster controller.
NewController creates a tikvcluster controller .