Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f0b7776
(bugfix): reduce frequency of update requests for CSVs
everettraven Oct 8, 2024
8db54cc
update unit tests
everettraven Oct 8, 2024
4e91464
updates to test so far
everettraven Oct 8, 2024
5cbee7b
Small changes
bentito Oct 9, 2024
a2690ec
Add metadata drift guard to copyToNamespace
bentito Apr 29, 2025
0b973b9
Tests for metadata guard
bentito Apr 29, 2025
f0a1d7e
Persist observed annotations on all status updates
bentito May 8, 2025
edfa12d
GCI the file
bentito May 19, 2025
e3130bb
Use TransformFunc
tmshort Jun 10, 2025
50c46e0
Update operatorgroup tests to compile
tmshort Jun 10, 2025
d6bf664
Restore operatorgroup_test from master
tmshort Jun 10, 2025
379e843
Remove more PartialObjectMetadata
tmshort Jun 10, 2025
c50f880
Remove hashes from operator_test
tmshort Jun 10, 2025
fc367b7
Fix error messages for static-analysis
tmshort Jun 10, 2025
3e3568f
Update test annotations and test client
tmshort Jun 10, 2025
fa84695
Rename pruning to listerwatcher
tmshort Jun 11, 2025
15f090a
Set resync to 6h
tmshort Jun 11, 2025
93a78a8
Add CSV copy revert syncer
tmshort Jun 11, 2025
d067f2c
Log tweaks
tmshort Jun 11, 2025
95f01aa
Consolidate revert and gc syncers
tmshort Jun 11, 2025
2cd56b4
Add logging and reduce the amount of metadata in the TransformFunc
tmshort Jun 11, 2025
ed9cb76
Handle the copy CSV revert via a requeue of the primary CSV
tmshort Jun 11, 2025
7d53e44
Revert "Set resync to 6h"
tmshort Jun 11, 2025
baca995
Add delete handler for copied csv
tmshort Jun 12, 2025
4c5d1be
Revert whitespace change
tmshort Jun 12, 2025
90919ed
Rename function, fix comment
tmshort Jun 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 42 additions & 27 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import (
olmerrors "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/errors"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog/subscription"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/internal/pruning"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/internal/listerwatcher"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/grpc"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/reconciler"
Expand Down Expand Up @@ -230,38 +230,53 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo

// Fields are pruned from local copies of the objects managed
// by this informer in order to reduce cached size.
prunedCSVInformer := cache.NewSharedIndexInformer(
pruning.NewListerWatcher(op.client, metav1.NamespaceAll,
prunedCSVInformer := cache.NewSharedIndexInformerWithOptions(
listerwatcher.NewListerWatcher(
op.client,
metav1.NamespaceAll,
func(options *metav1.ListOptions) {
options.LabelSelector = fmt.Sprintf("!%s", v1alpha1.CopiedLabelKey)
},
pruning.PrunerFunc(func(csv *v1alpha1.ClusterServiceVersion) {
*csv = v1alpha1.ClusterServiceVersion{
TypeMeta: csv.TypeMeta,
ObjectMeta: metav1.ObjectMeta{
Name: csv.Name,
Namespace: csv.Namespace,
Labels: csv.Labels,
Annotations: csv.Annotations,
},
Spec: v1alpha1.ClusterServiceVersionSpec{
CustomResourceDefinitions: csv.Spec.CustomResourceDefinitions,
APIServiceDefinitions: csv.Spec.APIServiceDefinitions,
Replaces: csv.Spec.Replaces,
Version: csv.Spec.Version,
},
Status: v1alpha1.ClusterServiceVersionStatus{
Phase: csv.Status.Phase,
Reason: csv.Status.Reason,
},
}
})),
),
&v1alpha1.ClusterServiceVersion{},
resyncPeriod(),
cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
cache.SharedIndexInformerOptions{
ResyncPeriod: resyncPeriod(),
Indexers: cache.Indexers{
cache.NamespaceIndex: cache.MetaNamespaceIndexFunc,
},
},
)

// Transformed the CSV to be just the necessary data
prunedCSVTransformFunc := func(i interface{}) (interface{}, error) {
if csv, ok := i.(*v1alpha1.ClusterServiceVersion); ok {
*csv = v1alpha1.ClusterServiceVersion{
TypeMeta: csv.TypeMeta,
ObjectMeta: metav1.ObjectMeta{
Name: csv.Name,
Namespace: csv.Namespace,
Labels: csv.Labels,
Annotations: csv.Annotations,
},
Spec: v1alpha1.ClusterServiceVersionSpec{
CustomResourceDefinitions: csv.Spec.CustomResourceDefinitions,
APIServiceDefinitions: csv.Spec.APIServiceDefinitions,
Replaces: csv.Spec.Replaces,
Version: csv.Spec.Version,
},
Status: v1alpha1.ClusterServiceVersionStatus{
Phase: csv.Status.Phase,
Reason: csv.Status.Reason,
},
}
return csv, nil
}
return nil, fmt.Errorf("unable to convert input to CSV")
}

if err := prunedCSVInformer.SetTransform(prunedCSVTransformFunc); err != nil {
return nil, err
}
csvLister := operatorsv1alpha1listers.NewClusterServiceVersionLister(prunedCSVInformer.GetIndexer())
op.lister.OperatorsV1alpha1().RegisterClusterServiceVersionLister(metav1.NamespaceAll, csvLister)
if err := op.RegisterInformer(prunedCSVInformer); err != nil {
Expand Down
25 changes: 25 additions & 0 deletions pkg/controller/operators/internal/listerwatcher/listerwatcher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package listerwatcher

import (
"context"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/tools/cache"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
)

func NewListerWatcher(client versioned.Interface, namespace string, override func(*metav1.ListOptions)) cache.ListerWatcher {
return &cache.ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
override(&options)
return client.OperatorsV1alpha1().ClusterServiceVersions(namespace).List(context.TODO(), options)
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
override(&options)
return client.OperatorsV1alpha1().ClusterServiceVersions(namespace).Watch(context.TODO(), options)
},
}
}
52 changes: 0 additions & 52 deletions pkg/controller/operators/internal/pruning/listerwatcher.go

This file was deleted.

Loading