Skip to content

Commit 19493a2

Browse files
committed
Removes global filters option
1 parent 46f6a5b commit 19493a2

File tree

2 files changed

+19
-44
lines changed

2 files changed

+19
-44
lines changed

pkg/controller/registry/resolver/cache/cache.go

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,13 @@ type OperatorCacheProvider interface {
7676
}
7777

7878
type Cache struct {
79-
logger logrus.StdLogger
80-
sp SourceProvider
81-
catsrcLister v1alpha1.CatalogSourceLister
82-
snapshots map[SourceKey]*snapshotHeader
83-
ttl time.Duration
84-
sem chan struct{}
85-
m sync.RWMutex
86-
globalFilters []Predicate
79+
logger logrus.StdLogger
80+
sp SourceProvider
81+
catsrcLister v1alpha1.CatalogSourceLister
82+
snapshots map[SourceKey]*snapshotHeader
83+
ttl time.Duration
84+
sem chan struct{}
85+
m sync.RWMutex
8786
}
8887

8988
type catalogSourcePriority int
@@ -104,12 +103,6 @@ func WithCatalogSourceLister(catalogSourceLister v1alpha1.CatalogSourceLister) O
104103
}
105104
}
106105

107-
func WithGlobalFilters(globalFilters ...Predicate) Option {
108-
return func(c *Cache) {
109-
c.globalFilters = globalFilters
110-
}
111-
}
112-
113106
func New(sp SourceProvider, options ...Option) *Cache {
114107
const (
115108
MaxConcurrentSnapshotUpdates = 4
@@ -121,12 +114,11 @@ func New(sp SourceProvider, options ...Option) *Cache {
121114
logger.SetOutput(io.Discard)
122115
return logger
123116
}(),
124-
sp: sp,
125-
catsrcLister: operatorlister.NewLister().OperatorsV1alpha1().CatalogSourceLister(),
126-
snapshots: make(map[SourceKey]*snapshotHeader),
127-
ttl: 5 * time.Minute,
128-
sem: make(chan struct{}, MaxConcurrentSnapshotUpdates),
129-
globalFilters: make([]Predicate, 0),
117+
sp: sp,
118+
catsrcLister: operatorlister.NewLister().OperatorsV1alpha1().CatalogSourceLister(),
119+
snapshots: make(map[SourceKey]*snapshotHeader),
120+
ttl: 5 * time.Minute,
121+
sem: make(chan struct{}, MaxConcurrentSnapshotUpdates),
130122
}
131123

132124
for _, opt := range options {
@@ -137,9 +129,8 @@ func New(sp SourceProvider, options ...Option) *Cache {
137129
}
138130

139131
type NamespacedOperatorCache struct {
140-
existing *SourceKey
141-
snapshots map[SourceKey]*snapshotHeader
142-
globalFilters []Predicate
132+
existing *SourceKey
133+
snapshots map[SourceKey]*snapshotHeader
143134
}
144135

145136
func (c *NamespacedOperatorCache) Error() error {
@@ -174,8 +165,7 @@ func (c *Cache) Namespaced(namespaces ...string) MultiCatalogOperatorFinder {
174165
sources := c.sp.Sources(namespaces...)
175166

176167
result := NamespacedOperatorCache{
177-
snapshots: make(map[SourceKey]*snapshotHeader),
178-
globalFilters: c.globalFilters,
168+
snapshots: make(map[SourceKey]*snapshotHeader),
179169
}
180170

181171
var misses []SourceKey
@@ -277,10 +267,6 @@ func (c *NamespacedOperatorCache) FindPreferred(preferred *SourceKey, preferredN
277267
preferred = nil
278268
}
279269

280-
if c.globalFilters != nil {
281-
p = append(p, c.globalFilters...)
282-
}
283-
284270
sorted := newSortableSnapshots(c.existing, preferred, preferredNamespace, c.snapshots)
285271
sort.Sort(sorted)
286272
for _, snapshot := range sorted.snapshots {

pkg/controller/registry/resolver/resolver.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import (
77
"sort"
88
"strings"
99

10-
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/runtime_constraints"
11-
1210
"github.com/blang/semver/v4"
1311
"github.com/sirupsen/logrus"
1412
utilerrors "k8s.io/apimachinery/pkg/util/errors"
@@ -17,15 +15,12 @@ import (
1715
v1alpha1listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1alpha1"
1816
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/cache"
1917
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/projection"
18+
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/runtime_constraints"
2019
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/solver"
2120
"github.com/operator-framework/operator-registry/pkg/api"
2221
opregistry "github.com/operator-framework/operator-registry/pkg/registry"
2322
)
2423

25-
const (
26-
runtimeConstraintsFilePath = "runtime_constraints.json"
27-
)
28-
2924
type OperatorResolver interface {
3025
SolveOperators(csvs []*v1alpha1.ClusterServiceVersion, subs []*v1alpha1.Subscription, add map[cache.OperatorSourceInfo]struct{}) (cache.OperatorSet, error)
3126
}
@@ -45,16 +40,10 @@ func NewDefaultSatResolver(rcp cache.SourceProvider, catsrcLister v1alpha1lister
4540
logger.Info("Cluster runtime constraints are in effect")
4641
}
4742

48-
// Two solutions:
49-
// #1: Global cache filters
50-
// globalFilters := cache.WithGlobalFilters(runtimeConstraintProvider.Constraints()...)
51-
5243
return &SatResolver{
53-
cache: cache.New(rcp, cache.WithLogger(logger), cache.WithCatalogSourceLister(catsrcLister) /*, globalFilters*/),
54-
log: logger,
55-
// #2: apply constraints in addInvariants
56-
runtimeConstraintsProvider: runtimeConstraintProvider, // uncomment when using option #2
57-
// runtimeConstraintsProvider: nil // uncomment when using option #1
44+
cache: cache.New(rcp, cache.WithLogger(logger), cache.WithCatalogSourceLister(catsrcLister)),
45+
log: logger,
46+
runtimeConstraintsProvider: runtimeConstraintProvider,
5847
}
5948
}
6049

0 commit comments

Comments
 (0)