@@ -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
@@ -510,15 +522,9 @@ type Context struct {
510
522
511
523
// NewControllerContext initializes the default Context for the current Options. It does
512
524
// not start any background processes.
513
- func (o * Options ) NewControllerContext (cb * ClientBuilder ) (* Context , error ) {
514
- client := cb .ClientOrDie ("shared-informer" )
525
+ func (o * Options ) NewControllerContext (cb * ClientBuilder , clusterVersionConfigInformerFactory , configInformerFactory configinformers.SharedInformerFactory ) (* Context , error ) {
515
526
kubeClient := cb .KubeClientOrDie (internal .ConfigNamespace , useProtobuf )
516
527
operatorClient := cb .OperatorClientOrDie ("operator-client" )
517
-
518
- clusterVersionConfigInformerFactory := configinformers .NewFilteredSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ), "" , func (opts * metav1.ListOptions ) {
519
- opts .FieldSelector = fmt .Sprintf ("metadata.name=%s" , o .Name )
520
- })
521
- configInformerFactory := configinformers .NewSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ))
522
528
openshiftConfigInformer := coreinformers .NewSharedInformerFactoryWithOptions (kubeClient , resyncPeriod (o .ResyncInterval ), coreinformers .WithNamespace (internal .ConfigNamespace ))
523
529
openshiftConfigManagedInformer := coreinformers .NewSharedInformerFactoryWithOptions (kubeClient , resyncPeriod (o .ResyncInterval ), coreinformers .WithNamespace (internal .ConfigManagedNamespace ))
524
530
operatorInformerFactory := operatorinformers .NewSharedInformerFactoryWithOptions (operatorClient , o .ResyncInterval ,
0 commit comments