Skip to content

Commit 8d1fb74

Browse files
operators/catalog: don't watch copied CSVs
As far as I can tell, we never do anything with them. Signed-off-by: Steve Kuznetsov <[email protected]>
1 parent 97071af commit 8d1fb74

File tree

6 files changed

+573
-122
lines changed

6 files changed

+573
-122
lines changed

pkg/controller/operators/catalog/operator.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,9 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
204204
// Fields are pruned from local copies of the objects managed
205205
// by this informer in order to reduce cached size.
206206
prunedCSVInformer := cache.NewSharedIndexInformer(
207-
pruning.NewListerWatcher(op.client, metav1.NamespaceAll, func(*metav1.ListOptions) {}, pruning.PrunerFunc(func(csv *v1alpha1.ClusterServiceVersion) {
207+
pruning.NewListerWatcher(op.client, metav1.NamespaceAll, func(options *metav1.ListOptions) {
208+
options.LabelSelector = fmt.Sprintf("!%s", v1alpha1.CopiedLabelKey)
209+
}, pruning.PrunerFunc(func(csv *v1alpha1.ClusterServiceVersion) {
208210
*csv = v1alpha1.ClusterServiceVersion{
209211
TypeMeta: csv.TypeMeta,
210212
ObjectMeta: metav1.ObjectMeta{

pkg/controller/operators/olm/operator.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
127127
if err := k8sscheme.AddToScheme(scheme); err != nil {
128128
return nil, err
129129
}
130+
if err := metav1.AddMetaToScheme(scheme); err != nil {
131+
return nil, err
132+
}
130133

131134
op := &Operator{
132135
Operator: queueOperator,
@@ -208,8 +211,7 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
208211
return nil, err
209212
}
210213

211-
// A separate informer solely for CSV copies. Fields
212-
// are pruned from local copies of the objects managed
214+
// A separate informer solely for CSV copies. Object metadata requests are used
213215
// by this informer in order to reduce cached size.
214216
gvr := v1alpha1.SchemeGroupVersion.WithResource("clusterserviceversions")
215217
copiedCSVInformer := metadatainformer.NewFilteredMetadataInformer(
@@ -221,18 +223,18 @@ func newOperatorWithConfig(ctx context.Context, config *operatorConfig) (*Operat
221223
func(options *metav1.ListOptions) {
222224
options.LabelSelector = v1alpha1.CopiedLabelKey
223225
},
224-
)
225-
op.copiedCSVLister = metadatalister.New(copiedCSVInformer.Informer().GetIndexer(), gvr)
226+
).Informer()
227+
op.copiedCSVLister = metadatalister.New(copiedCSVInformer.GetIndexer(), gvr)
226228

227229
// Register separate queue for gcing copied csvs
228230
copiedCSVGCQueue := workqueue.NewNamedRateLimitingQueue(workqueue.DefaultControllerRateLimiter(), fmt.Sprintf("%s/csv-gc", namespace))
229231
op.copiedCSVGCQueueSet.Set(namespace, copiedCSVGCQueue)
230232
copiedCSVGCQueueInformer, err := queueinformer.NewQueueInformer(
231233
ctx,
232-
queueinformer.WithInformer(copiedCSVInformer.Informer()),
234+
queueinformer.WithInformer(copiedCSVInformer),
233235
queueinformer.WithLogger(op.logger),
234236
queueinformer.WithQueue(copiedCSVGCQueue),
235-
queueinformer.WithIndexer(copiedCSVInformer.Informer().GetIndexer()),
237+
queueinformer.WithIndexer(copiedCSVInformer.GetIndexer()),
236238
queueinformer.WithSyncer(queueinformer.LegacySyncHandler(op.syncGcCsv).ToSyncer()),
237239
)
238240
if err != nil {

0 commit comments

Comments
 (0)