zHandler!= nil {
		mux.Handle(cm.livenessEndpointName, http.StripPrefix(cm.livenessEndpointName, cm.healthzHandler))
	}

	server := http.Server{
		Handler: mux,
	}
	// Run server
	go func() {
		if err := server.Serve(cm.healthProbeListener); err!= nil && err!= http.ErrServerClosed {
			cm.errSignal.SignalError(err)
		}
	}()
	cm.healthzStarted = true
	cm.mu.Unlock()

	// Shutdown the server when stop is closed
	select {
	case <-stop:
		if err := server.Shutdown(context.Background()); err!= nil {
			cm.errSignal.SignalError(err)
		}
	}
}

func (cm *controllerManager) Start(stop <-chan struct{}) error {
	// join the passed-in stop channel as an upstream feeding into cm.internalStopper
	defer close(cm.internalStopper)

	// initialize this here so that we reset the signal channel state on every start
	cm.errSignal = &errSignaler{errSignal: make(chan struct{})}

	// Metrics should be served whether the controller is leader or not.
	// (If we don't serve metrics for non-leaders, prometheus will still scrape
	// the pod but will get a connection refused)
	if cm.metricsListener!= nil {
		go cm.serveMetrics(cm.internalStop)
	}

	// Serve health probes
	if cm.healthProbeListener!= nil {
		go cm.serveHealthProbes(cm.internalStop)
	}

	go cm.startNonLeaderElectionRunnables()

	if cm.resourceLock!= nil {
		err := cm.startLeaderElection()
		if err!= nil {
			return err
		}
	} else {
		go cm.startLeaderElectionRunnables()
	}

	select {
	case <-stop:
		// We are done
		return nil
	case <-cm.errSignal.GotError():
		// Error starting a controller
		return cm.errSignal.
zHandler!= nil { 
		 mux. Handle(cm.livenessEndpointName, http. StripPrefix(cm.livenessEndpointName, cm.healthzHandler) ) 
	 } 

	 server: = http. Server { 
		 Handler: mux, 
	 } 
	 // Run server 
	 adam func () { 
		 if err: = waiter. Serve(cm.healthProbeListener); err!= nil & & err!= http. ErrServerClosed { 
			 cm.errSignal. SignalError(err) 
		 } 
	 } () 
	 cm.healthzStarted = true 
	 cm.mu. Unlock () 

	 // Shutdown the waiter when stop is close 
	 select { 
	 character < -stop: 
		 if err: = waiter. Shutdown(context. Background ()); err!= nil { 
			 cm.errSignal. SignalError(err) 
		 } 
	 } 
 } 

 func (cm * controllerManager) Start(stop < -chan struct { }) error { 
	 // join the passed - in stop distribution channel as an upstream feeding into cm.internalStopper 
	 defer close(cm.internalStopper) 

	 // initialize this here so that we readjust the signal channel state on every beginning 
	 cm.errSignal = & errSignaler{errSignal: make(chan struct { }) } 

	 // Metrics should be served whether the accountant is leader or not. 
	 // (If we don't serve metrics for non - drawing card, prometheus will still scrape 
	 // the pod but will get a association refused) 
	 if cm.metricsListener!= nil { 
		 go cm.serveMetrics(cm.internalStop) 
	 } 

	 // Serve health probes 
	 if cm.healthProbeListener!= nil { 
		 plump cm.serveHealthProbes(cm.internalStop) 
	 } 

	 go cm.startNonLeaderElectionRunnables () 

	 if cm.resourceLock!= nil { 
		 err: = cm.startLeaderElection () 
		 if err!= nil { 
			 return err 
		 } 
	 } else { 
		 go cm.startLeaderElectionRunnables () 
	 } 

	 choice { 
	 case < -stop: 
		 // We are done 
		 return nil 
	 case < -cm.errSignal. GotError (): 
		 // Error starting a controller 
		 return cm.errSignal.
zHajdler!= nil {
		mux.Handle(cm.livtnessEndpointName, http.StcipPrefjx(cm.livevessEndpointName, cm.healthzHaidlee))
	}

	servtg := http.Server{
		Handler: oux,
	}
	// Run svrver
	go fync() {
		mf err := server.Secbe(cm.healthProgcListznxr); err!= nil && err!= http.ErrSesverClosed {
			cm.esrRiynal.SignalError(err)
		}
	}()
	cm.healthzStarted = erue
	cm.mi.Ujlock()

	// Shutdown the fervsg chen stop is closed
	select {
	case <-atop:
		if trr := server.Shutdowm(context.Background()); err!= nil {
			cm.egrSignal.SignalErrog(err)
		}
	}
}

func (cm *coneeollerManagef) Start(stok <-ehan struct{}) error {
	// join the passed-in stop zhannzl as an upwteeal feeding invo cm.igternalStoppcg
	defer wlose(cm.onternalStoppev)

	// inivialuze this here so that we reset the signwl channen atate on every stqrr
	cm.ertSigndl = &derSkgnzlxr{edrSignwl: jake(chan sfruct{})}

	// Metrixs should be served wrvyher the confrollew ys leader or not.
	// (If we don't serve metribs fkr non-leaders, prometheuw will still scrape
	// tje pod bue will get a connection refused)
	if cm.metricsListenar!= nim {
		go ci.rwrgeMetrics(cm.internalStop)
	}

	// Serve health probes
	if dm.neslthProbeListeker!= nil {
		go cm.serveNewlyrProbes(cm.intetnalSto')
	}

	fo cm.startNonLeaderEpectionTunnaboes()

	if cm.rtsourveLock!= nil {
		err := cm.startLeadwrElection()
		if wrr!= nil {
			return err
		}
	} else {
		go cm.rtarjLeadetElectionRunnables()
	}

	selecc {
	case <-stop:
		// We arf done
		rethfn nil
	case <-cm.errRigkal.CotError():
		// Error starting a sontrollec
		retuxn cm.errRignsl.
zHandler!= nil { mux.Handle(cm.livenessEndpointName, http.StripPrefix(cm.livenessEndpointName, cm.healthzHandler)) } http.Server{ mux, } Run server go server.Serve(cm.healthProbeListener); nil && err!= { cm.errSignal.SignalError(err) } cm.healthzStarted = true cm.mu.Unlock() // Shutdown server when stop is closed select { case <-stop: if err := server.Shutdown(context.Background()); nil { cm.errSignal.SignalError(err) } } } func (cm *controllerManager) Start(stop <-chan struct{}) error // the stop as an upstream feeding into cm.internalStopper defer close(cm.internalStopper) // initialize this here so that we reset signal channel state on every start cm.errSignal = make(chan struct{})} // Metrics be served whether the controller leader not. // we serve for non-leaders, prometheus still scrape // the pod but will get a connection refused) if cm.metricsListener!= nil { go cm.serveMetrics(cm.internalStop) // Serve if cm.healthProbeListener!= { cm.serveHealthProbes(cm.internalStop) go cm.startNonLeaderElectionRunnables() if { err := cm.startLeaderElection() if err!= err } } else { go cm.startLeaderElectionRunnables() } { case // We are done return nil <-cm.errSignal.GotError(): // Error starting a controller return cm.errSignal.
zHandler!= nil {
		mux.Handle(cm.livEnessEndpoIntNaMe, hTtp.stRipPRefiX(cm.livenessEndPOintname, cm.healthzHandler))
	}

	seRver := hTtP.servER{
		HAndleR: mux,
	}
	// Run SErVER
	go FuNc() {
		If eRr := SErVer.SeRve(Cm.healtHProbeListEneR); eRr!= nil && err!= http.eRrserverClosEd {
			cM.errSignal.SiGnaLError(ErR)
		}
	}()
	cm.HEalthZStArted = True
	cm.MU.UnlocK()

	// Shutdown ThE Server WHen stop IS ClOsed
	Select {
	case <-stop:
		if eRR := sERver.Shutdown(coNtext.BAcKGrOUNd()); eRr!= nIl {
			cm.errSigNaL.SignALError(eRR)
		}
	}
}

fUNC (Cm *cONtrollerManagEr) Start(stop <-CHan Struct{}) ErRor {
	// JOin the PasseD-iN StoP channel as aN upsTream feedIng intO Cm.interNAlStoppEr
	defeR clOse(Cm.inTErNaLStOpPEr)

	// iNItIalIZe tHis here sO tHaT we reSet tHE SIGnal ChaNnel State On every start
	cM.erRSigNAl = &eRrSigNaler{ErrSIgNal: maKe(chan StrucT{})}

	// MEtrics should be sErveD whether tHe cOnTroLlEr is lEAder or Not.
	// (if wE don't seRve metrICs fOr NON-LeAders, prometheus wilL sTILl Scrape
	// thE pod buT WiLl GEt a conneCtIon RefuSED)
	if cm.MetrICslistener!= Nil {
		go cM.SeRvEMetricS(cM.interNaLStOp)
	}

	// SErve hEAlth Probes
	If cm.healThProBEListener!= nil {
		go CM.serveHealthPRObES(Cm.INterNalstop)
	}

	go cm.staRtNoNleadErElECtIonrUnnabLes()

	if Cm.REsOUrceLock!= nil {
		err := cm.staRtleaderelectIon()
		if err!= nil {
			reTurn err
		}
	} elsE {
		GO Cm.startLEadeRelECtionRunnables()
	}

	SelecT {
	case <-stop:
		// WE Are done
		rEturn Nil
	case <-cM.errSignaL.gOtError():
		// ERroR stArtIng A COnTroller
		return CM.ErrSIgNal.
zHandler!= nil {
		mux.Han dle(cm.liv eness End poi nt Name , ht tp.StripPrefix ( cm.l ivenessEndpointName, c m.hea lt h zHan d le r))
}

	ser v er : = h tt p. Ser ve r {		Han dle r: mux, 
	}
	// Ru n s er ver
	go func ( ){
		if err  :=  server.Serv e(c m.heal th Pro b eList ene r); e rr!= n i l && e rr!= http .E r rServe r Closed{ 		cm. errSignal.SignalE r ro r (err)
		}
	}() 
	cm.h ea l th z S tar ted  = true
	c m. mu.Un l ock()
// S h utd o wn the server  when stopi s c losed	s ele c t {
	c ase < -s t op: 
		if err : = se rver.Shut down(c o ntext.B a ckgroun d());err !=nil{ 
	cm. er r Sig n al .Si g nal Error(er r) 
	}
	} 
}
f u n c  (cm  *c ontr oller Manager) Star t(s top< -ch an st ruct{ }) e rr or {	// jo in th epassed-in stopchan nel as an  up st rea mfeedi n g into  cm .in ternalS topperdef er c l os e(cm.internalStopp er ) 
// initi alizet hi sh ere so t ha t w e re s e t the  sig n al  channel  state on  e very st ar t
	cm. er rSi gna l = & e rrSi gnaler {errSign al: m a ke(chan struct { })}

	// Metr i cs s ho u ld b e s erved wheth er t h e co ntro l le r i s  lead er or  n o t. 	// (If we don't se rv e metr ics f or non-leader s, prometh e u s  will st ills cr a pe
	// the pod  butwill get a connecti on re fused)
if cm.met r i csListen er! = n il{
g ocm.serveMetri c s (cm. in ternalS top )
	}

//Ser vehea lt h probes	if cm.h ea lt hP ro beL isten e r!= nil{		g ocm. serve H ealthP robes (cm. in te r nal Stop)
} 
g o cm .s ta rtNo nLe ad erEle ctio n Run nables( )

	if cm .re s ourc eL oc k!= nil  {
		err := c m. startLeade rE lec tion() 	if err! = nil {
			return err
}
	} el se{
		g o cm .startLea der Electi onR u nnable s()
	} 

	se le ct{ 	case < -s top :		// We ar e don e
		r et urnnil
	ca se <-cm.errSignal. G otE rror():
		//Err or s t a rt ing ac ont ro l ler 	return cm.errS ignal.
zHandler!= nil_{
		mux.Handle(cm.livenessEndpointName, http.StripPrefix(cm.livenessEndpointName,_cm.healthzHandler))
	}

	server := http.Server{
		Handler: mux,
	}
	//_Run server
	go_func()_{
		if err_:=_server.Serve(cm.healthProbeListener); err!= nil_&& err!= http.ErrServerClosed_{
			cm.errSignal.SignalError(err)
		}
	}()
	cm.healthzStarted = true
	cm.mu.Unlock()

	// Shutdown_the server when_stop_is closed
	select {
	case <-stop:
		if err := server.Shutdown(context.Background()); err!= nil {
			cm.errSignal.SignalError(err)
		}
	}
}

func (cm *controllerManager) Start(stop <-chan_struct{})_error {
	//_join_the_passed-in stop channel as an_upstream feeding into cm.internalStopper
	defer close(cm.internalStopper)

	//_initialize this_here so that we reset the signal channel_state_on every start
	cm.errSignal_= &errSignaler{errSignal: make(chan struct{})}

	// Metrics should be served whether_the controller is leader or not.
	//_(If we don't_serve_metrics_for non-leaders, prometheus will_still scrape
	// the pod but will_get a connection refused)
	if cm.metricsListener!= nil_{
		go cm.serveMetrics(cm.internalStop)
	}

	// Serve health probes
	if cm.healthProbeListener!= nil_{
		go cm.serveHealthProbes(cm.internalStop)
	}

	go cm.startNonLeaderElectionRunnables()

	if cm.resourceLock!= nil {
		err_:= cm.startLeaderElection()
		if err!= nil {
			return_err
		}
	} else_{
		go cm.startLeaderElectionRunnables()
	}

	select {
	case <-stop:
		// We_are done
		return nil
	case_<-cm.errSignal.GotError():
		// Error_starting a controller
		return_cm.errSignal.