Skip to content

Commit a3a7cfc

Browse files
committed
Use ReaderFailOnMissingInformer for cache options
When controller makes queries with client.{Get,List} on resources haven’t been declared upfront, controller-runtime will initialize an informer on-the-fly and block on warming up its cache. This leads to issues like: * controller-runtime starting a watch for a resource type and start caching all its objects in memory (even if you were trying to query only one resource), potentially leading to the process running out of memory. * unpredictable reconciliation times while the informer cache is syncing, during which your worker goroutine will be blocked from reconciling other resources. Signed-off-by: Bohdan Dobrelia <[email protected]>
1 parent 80229e1 commit a3a7cfc

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3333
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
3434
ctrl "sigs.k8s.io/controller-runtime"
35+
cache "sigs.k8s.io/controller-runtime/pkg/cache"
3536
"sigs.k8s.io/controller-runtime/pkg/client/config"
3637
"sigs.k8s.io/controller-runtime/pkg/healthz"
3738
"sigs.k8s.io/controller-runtime/pkg/log/zap"
@@ -97,6 +98,7 @@ func main() {
9798
BindAddress: metricsAddr,
9899
},
99100
HealthProbeBindAddress: probeAddr,
101+
Cache: cache.Options{ReaderFailOnMissingInformer: false},
100102
LeaderElection: enableLeaderElection,
101103
LeaderElectionID: "73d6b7ce.openstack.org",
102104
WebhookServer: webhook.NewServer(

0 commit comments

Comments
 (0)