Skip to content

Commit 7f04416

Browse files
committed
improve cache
1 parent 2e45015 commit 7f04416

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

internal/controller/demoloki/demoloki_objects.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ func newBuilder(info *reconcilers.Instance, desired *flowslatest.FlowCollectorSp
4242
return builder{
4343
info: info,
4444
labels: map[string]string{
45-
"app": name,
45+
"part-of": constants.OperatorName,
46+
"app": name,
4647
},
4748
selector: map[string]string{
4849
"app": name,

internal/pkg/manager/manager.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ import (
55
"fmt"
66

77
flowslatest "github.com/netobserv/netobserv-operator/api/flowcollector/v1beta2"
8+
"github.com/netobserv/netobserv-operator/internal/controller/constants"
89
"github.com/netobserv/netobserv-operator/internal/pkg/cluster"
910
"github.com/netobserv/netobserv-operator/internal/pkg/manager/status"
1011
"github.com/netobserv/netobserv-operator/internal/pkg/migrator"
1112
"github.com/netobserv/netobserv-operator/internal/pkg/narrowcache"
13+
corev1 "k8s.io/api/core/v1"
14+
"k8s.io/apimachinery/pkg/labels"
1215
"k8s.io/client-go/discovery"
1316
"k8s.io/client-go/rest"
1417
ctrl "sigs.k8s.io/controller-runtime"
18+
"sigs.k8s.io/controller-runtime/pkg/cache"
1519
"sigs.k8s.io/controller-runtime/pkg/client"
1620
"sigs.k8s.io/controller-runtime/pkg/log"
1721
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -86,6 +90,13 @@ func NewManager(
8690
narrowcache.EndpointSlices,
8791
)
8892
opts.Client = client.Options{Cache: narrowCache.ControllerRuntimeClientCacheOptions()}
93+
opts.Cache = cache.Options{
94+
ByObject: map[client.Object]cache.ByObject{
95+
&corev1.Pod{}: {
96+
Label: labels.SelectorFromSet(map[string]string{"part-of": constants.OperatorName}),
97+
},
98+
},
99+
}
89100

90101
internalManager, err := ctrl.NewManager(kcfg, *opts)
91102
if err != nil {

0 commit comments

Comments
 (0)