@@ -186,30 +186,6 @@ func New(
186186 return ctrl
187187}
188188
189- // waitForControllerConfig waits for the ControllerConfig to be reconciled by the template controller
190- func (ctrl * Controller ) waitForControllerConfig (stopCh <- chan struct {}) error {
191- klog .Info ("Waiting for ControllerConfig generation to be reconciled..." )
192-
193- ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Minute )
194- defer cancel ()
195-
196- return wait .PollUntilContextTimeout (ctx , 5 * time .Second , 5 * time .Minute , true , func (_ context.Context ) (bool , error ) {
197- select {
198- case <- stopCh :
199- return false , fmt .Errorf ("controller stopped while waiting for ControllerConfig reconciliation" )
200- default :
201- }
202-
203- if err := apihelpers .IsControllerConfigRunningOrCompleted (ctrlcommon .ControllerConfigName , ctrl .ccLister .Get ); err != nil {
204- // If the ControllerConfig is not running, we will encounter an error when generating the
205- // kubeletconfig object.
206- klog .V (1 ).Infof ("ControllerConfig not running: %v" , err )
207- return false , nil
208- }
209- return true , nil
210- })
211- }
212-
213189// Run executes the kubelet config controller.
214190func (ctrl * Controller ) Run (workers int , stopCh <- chan struct {}) {
215191 defer utilruntime .HandleCrash ()
@@ -248,6 +224,31 @@ func (ctrl *Controller) Run(workers int, stopCh <-chan struct{}) {
248224
249225 <- stopCh
250226}
227+
228+ // waitForControllerConfig waits for the ControllerConfig to be reconciled by the template controller
229+ func (ctrl * Controller ) waitForControllerConfig (stopCh <- chan struct {}) error {
230+ klog .Info ("Waiting for ControllerConfig generation to be reconciled..." )
231+
232+ ctx , cancel := context .WithTimeout (context .Background (), 5 * time .Minute )
233+ defer cancel ()
234+
235+ return wait .PollUntilContextTimeout (ctx , 5 * time .Second , 5 * time .Minute , true , func (_ context.Context ) (bool , error ) {
236+ select {
237+ case <- stopCh :
238+ return false , fmt .Errorf ("controller stopped while waiting for ControllerConfig reconciliation" )
239+ default :
240+ }
241+
242+ if err := apihelpers .IsControllerConfigRunningOrCompleted (ctrlcommon .ControllerConfigName , ctrl .ccLister .Get ); err != nil {
243+ // If the ControllerConfig is not running, we will encounter an error when generating the
244+ // kubeletconfig object.
245+ klog .V (1 ).Infof ("ControllerConfig not running: %v" , err )
246+ return false , nil
247+ }
248+ return true , nil
249+ })
250+ }
251+
251252func (ctrl * Controller ) filterAPIServer (apiServer * configv1.APIServer ) {
252253 if apiServer .Name != "cluster" {
253254 return
0 commit comments