Skip to content

Commit b6094ff

Browse files
OCPNODE-3201: Create MC to preserve 4.20 kubeletconfig post upgrade
1 parent 7c5e77d commit b6094ff

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

pkg/controller/kubelet-config/kubelet_config_controller.go

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
214190
func (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+
251252
func (ctrl *Controller) filterAPIServer(apiServer *configv1.APIServer) {
252253
if apiServer.Name != "cluster" {
253254
return

0 commit comments

Comments
 (0)