Skip to content

Commit 30ac15c

Browse files
committed
fix(catalog): fill the csv cache with informers
1 parent 0b3bfb0 commit 30ac15c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,12 @@ func NewOperator(kubeconfigPath string, logger *logrus.Logger, wakeupInterval ti
8989
// Create an informer for each watched namespace.
9090
ipSharedIndexInformers := []cache.SharedIndexInformer{}
9191
subSharedIndexInformers := []cache.SharedIndexInformer{}
92+
csvSharedIndexInformers := []cache.SharedIndexInformer{}
9293
for _, namespace := range watchedNamespaces {
9394
nsInformerFactory := externalversions.NewSharedInformerFactoryWithOptions(crClient, wakeupInterval, externalversions.WithNamespace(namespace))
9495
ipSharedIndexInformers = append(ipSharedIndexInformers, nsInformerFactory.Operators().V1alpha1().InstallPlans().Informer())
9596
subSharedIndexInformers = append(subSharedIndexInformers, nsInformerFactory.Operators().V1alpha1().Subscriptions().Informer())
97+
csvSharedIndexInformers = append(csvSharedIndexInformers, nsInformerFactory.Operators().V1alpha1().ClusterServiceVersions().Informer())
9698

9799
// resolver needs subscription and csv listers
98100
lister.OperatorsV1alpha1().RegisterSubscriptionLister(namespace, nsInformerFactory.Operators().V1alpha1().Subscriptions().Lister())
@@ -230,6 +232,11 @@ func NewOperator(kubeconfigPath string, logger *logrus.Logger, wakeupInterval ti
230232
op.lister.CoreV1().RegisterNamespaceLister(namespaceInformer.Lister())
231233
op.namespaceResolveQueue = resolvingNamespaceQueue
232234

235+
// Register CSV informers to fill cache
236+
for _, informer := range csvSharedIndexInformers {
237+
op.RegisterInformer(informer)
238+
}
239+
233240
return op, nil
234241
}
235242

pkg/controller/registry/resolver/resolver.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,20 @@ func (r *OperatorsV1alpha1Resolver) ResolveSteps(namespace string, sourceQuerier
4141
}
4242

4343
// create a generation - a representation of the current set of installed operators and their provided/required apis
44-
csvs, err := r.csvLister.ClusterServiceVersions(namespace).List(labels.Everything())
44+
allCSVs, err := r.csvLister.ClusterServiceVersions(namespace).List(labels.Everything())
4545
if err != nil {
4646
return nil, nil, err
4747
}
48+
49+
// TODO: build this index ahead of time
50+
// omit copied csvs from generation - they indicate that apis are provided to the namespace, not by the namespace
51+
var csvs []*v1alpha1.ClusterServiceVersion
52+
for _, c := range allCSVs {
53+
if !c.IsCopied() {
54+
csvs = append(csvs, c)
55+
}
56+
}
57+
4858
subs, err := r.subLister.Subscriptions(namespace).List(labels.Everything())
4959
if err != nil {
5060
return nil, nil, err

0 commit comments

Comments
 (0)