@@ -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,22 +522,17 @@ 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
openshiftConfigInformerFactory := coreinformers .NewSharedInformerFactoryWithOptions (kubeClient , resyncPeriod (o .ResyncInterval ), coreinformers .WithNamespace (internal .ConfigNamespace ))
517
528
openshiftConfigManagedInformerFactory := coreinformers .NewSharedInformerFactoryWithOptions (kubeClient , resyncPeriod (o .ResyncInterval ), coreinformers .WithNamespace (internal .ConfigManagedNamespace ))
518
529
519
- clusterVersionConfigInformerFactory := configinformers .NewFilteredSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ), "" , func (opts * metav1.ListOptions ) {
520
- opts .FieldSelector = fmt .Sprintf ("metadata.name=%s" , o .Name )
521
- })
522
- configInformerFactory := configinformers .NewSharedInformerFactory (client , resyncPeriod (o .ResyncInterval ))
523
-
524
530
operatorClient := cb .OperatorClientOrDie ("operator-client" )
525
531
filterByName := func (opts * metav1.ListOptions ) {
526
532
opts .FieldSelector = fields .OneTermEqualSelector ("metadata.name" , configuration .ClusterVersionOperatorConfigurationName ).String ()
527
533
}
528
534
operatorInformerFactory := operatorinformers .NewSharedInformerFactoryWithOptions (operatorClient , o .ResyncInterval , operatorinformers .WithTweakListOptions (filterByName ))
535
+
529
536
coInformer := configInformerFactory .Config ().V1 ().ClusterOperators ()
530
537
531
538
cvoKubeClient := cb .KubeClientOrDie (o .Namespace , useProtobuf )
0 commit comments