Skip to content

Commit

Permalink
catalog: Add an OG informer and register a lister
Browse files Browse the repository at this point in the history
Signed-off-by: timflannagan <timflannagan@gmail.com>
  • Loading branch information
timflannagan authored and openshift-merge-robot committed Apr 14, 2022
1 parent 918a4d1 commit 73a2b07
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 73a2b07

Please sign in to comment.