From 73a2b072172e34b036ebe9fa83b1a6a5bb3259a3 Mon Sep 17 00:00:00 2001 From: timflannagan Date: Thu, 14 Apr 2022 10:24:06 -0400 Subject: [PATCH] catalog: Add an OG informer and register a lister Signed-off-by: timflannagan --- pkg/controller/operators/catalog/operator.go | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/pkg/controller/operators/catalog/operator.go b/pkg/controller/operators/catalog/operator.go index 733344eb29..da2994ac3c 100644 --- a/pkg/controller/operators/catalog/operator.go +++ b/pkg/controller/operators/catalog/operator.go @@ -103,6 +103,7 @@ type Operator struct { catsrcQueueSet *queueinformer.ResourceQueueSet subQueueSet *queueinformer.ResourceQueueSet ipQueueSet *queueinformer.ResourceQueueSet + ogQueueSet *queueinformer.ResourceQueueSet nsResolveQueue workqueue.RateLimitingInterface namespace string recorder record.EventRecorder @@ -182,6 +183,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo catsrcQueueSet: queueinformer.NewEmptyResourceQueueSet(), subQueueSet: queueinformer.NewEmptyResourceQueueSet(), ipQueueSet: queueinformer.NewEmptyResourceQueueSet(), + ogQueueSet: queueinformer.NewEmptyResourceQueueSet(), catalogSubscriberIndexer: map[string]cache.Indexer{}, serviceAccountQuerier: scoped.NewUserDefinedServiceAccountQuerier(logger, crClient), clientAttenuator: scoped.NewClientAttenuator(logger, config, opClient), @@ -256,6 +258,24 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo return nil, err } + operatorGroupInformer := crInformerFactory.Operators().V1().OperatorGroups() + op.lister.OperatorsV1().RegisterOperatorGroupLister(metav1.NamespaceAll, operatorGroupInformer.Lister()) + ogQueue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), "ogs") + op.ogQueueSet.Set(metav1.NamespaceAll, ogQueue) + operatorGroupQueueInformer, err := queueinformer.NewQueueInformer( + ctx, + queueinformer.WithLogger(op.logger), + queueinformer.WithQueue(ogQueue), + queueinformer.WithInformer(operatorGroupInformer.Informer()), + queueinformer.WithSyncer(queueinformer.LegacySyncHandler(op.syncResolvingNamespace).ToSyncer()), + ) + if err != nil { + return nil, err + } + if err := op.RegisterQueueInformer(operatorGroupQueueInformer); err != nil { + return nil, err + } + // Wire CatalogSources catsrcInformer := crInformerFactory.Operators().V1alpha1().CatalogSources() op.lister.OperatorsV1alpha1().RegisterCatalogSourceLister(metav1.NamespaceAll, catsrcInformer.Lister()) @@ -886,6 +906,7 @@ func (o *Operator) syncCatalogSources(obj interface{}) (syncError error) { func (o *Operator) isFailForwardEnabled(namespace string) (bool, error) { ogs, err := o.lister.OperatorsV1().OperatorGroupLister().OperatorGroups(namespace).List(labels.Everything()) if err != nil { + o.logger.Debugf("failed to list operatorgroups in the %s namespace: %v", namespace, err) // Couldn't list operatorGroups, assuming default upgradeStrategy // so existing behavior is observed for failed CSVs. return false, nil