@@ -214,8 +214,10 @@ func (o *Options) Run(ctx context.Context) error {
214
214
klog .Infof ("Determined OCP version for this CVO: %q" , cvoOcpVersion )
215
215
}
216
216
217
+ clusterVersionConfigInformerFactory , configInformerFactory := o .prepareConfigInformerFactories (cb )
218
+
217
219
// initialize the controllers and attempt to load the payload information
218
- controllerCtx , err := o .NewControllerContext (cb )
220
+ controllerCtx , err := o .NewControllerContext (cb , clusterVersionConfigInformerFactory , configInformerFactory )
219
221
if err != nil {
220
222
return err
221
223
}
@@ -224,6 +226,16 @@ func (o *Options) Run(ctx context.Context) error {
224
226
return nil
225
227
}
226
228
229
+ func (o * Options ) prepareConfigInformerFactories (cb * ClientBuilder ) (configinformers.SharedInformerFactory , configinformers.SharedInformerFactory ) {
230
+ client := cb .ClientOrDie ("shared-informer" )
231
+ clusterVersionConfigInformerFactory := configinformers .NewFilteredSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ), "" , func (opts * metav1.ListOptions ) {
232
+ opts .FieldSelector = fmt .Sprintf ("metadata.name=%s" , o .Name )
233
+ })
234
+ configInformerFactory := configinformers .NewSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ))
235
+
236
+ return clusterVersionConfigInformerFactory , configInformerFactory
237
+ }
238
+
227
239
// run launches a number of goroutines to handle manifest application,
228
240
// metrics serving, etc. It continues operating until ctx.Done(),
229
241
// and then attempts a clean shutdown limited by an internal context
@@ -500,15 +512,9 @@ type Context struct {
500
512
501
513
// NewControllerContext initializes the default Context for the current Options. It does
502
514
// not start any background processes.
503
- func (o * Options ) NewControllerContext (cb * ClientBuilder ) (* Context , error ) {
504
- client := cb .ClientOrDie ("shared-informer" )
515
+ func (o * Options ) NewControllerContext (cb * ClientBuilder , clusterVersionConfigInformerFactory , configInformerFactory configinformers.SharedInformerFactory ) (* Context , error ) {
505
516
kubeClient := cb .KubeClientOrDie (internal .ConfigNamespace , useProtobuf )
506
517
operatorClient := cb .OperatorClientOrDie ("operator-client" )
507
-
508
- clusterVersionConfigInformerFactory := configinformers .NewFilteredSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ), "" , func (opts * metav1.ListOptions ) {
509
- opts .FieldSelector = fmt .Sprintf ("metadata.name=%s" , o .Name )
510
- })
511
- configInformerFactory := configinformers .NewSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ))
512
518
openshiftConfigInformer := coreinformers .NewSharedInformerFactoryWithOptions (kubeClient , resyncPeriod (o .ResyncInterval ), coreinformers .WithNamespace (internal .ConfigNamespace ))
513
519
openshiftConfigManagedInformer := coreinformers .NewSharedInformerFactoryWithOptions (kubeClient , resyncPeriod (o .ResyncInterval ), coreinformers .WithNamespace (internal .ConfigManagedNamespace ))
514
520
operatorInformerFactory := operatorinformers .NewSharedInformerFactoryWithOptions (operatorClient , o .ResyncInterval ,
0 commit comments