11Cache Options
22===================
33
4- This document describes how we imagine the cache options to look like in
4+ This document describes how we imagine the cache options to look in
55the future.
66
77## Goals
@@ -13,9 +13,9 @@ the future.
1313
1414## Non-Goals
1515
16- * Line out how the actual implementation of the cache itself will look like .
16+ * Describe the design and implementation of the cache itself.
1717 The assumption is that the most granular level we will end up with is
18- "per object multiple namespaces with distinct selectors" and that this
18+ "per- object multiple namespaces with distinct selectors" and that this
1919 can be implemented using a "meta cache" that delegates per object and by
2020 extending the current multi-namespace cache
2121* Outline any kind of timeline for when these settings will be implemented.
@@ -26,6 +26,11 @@ the future.
2626
2727
2828```
29+
30+ const (
31+ AllNamespaces = corev1.NamespaceAll
32+ )
33+
2934type CacheSetting struct {
3035 // LabelSelector specifies a label selector. A nil value allows to
3136 // default this.
@@ -54,21 +59,21 @@ type ByObject struct {
5459 // An empty value in this map means "No Selectors".
5560 //
5661 // It is possible to have specific CacheSettings for just some namespaces
57- // but cache all namespaces by using the empty string as map key for
58- // "all namespaces". This wil then include all namespaces that do not have
59- // a more specific setting.
62+ // but cache all namespaces by using the AllNamespaces const as the map key.
63+ // This wil then include all namespaces that do not have a more specific
64+ // setting.
6065 //
61- // A nil map allows to default this to the caches DefaultNamespaces setting.
66+ // A nil map allows to default this to the cache's DefaultNamespaces setting.
6267 // An empty map prevents this.
6368 //
6469 // This must be unset for cluster-scoped objects.
6570 Namespaces map[string]*CacheSetting
6671
67- // CacheSettings will be used if Namespaces is empty or for entries in
68- // Namespaces that have a nil value .
72+ // CacheSettings will be used for cluster-scoped objects and to default
73+ // CacheSettings in the Namespaces field .
6974 //
70- // If nil, this will be defaulted to the caches DefaultLabelSelector,
71- // DefaultFieldSelector and DefaultTransform.
75+ // It gets defaulted from DefaultLabelSelector, DefaultFieldSelector ,
76+ // DefaultUnsafeDisableDeepCopy and DefaultTransform.
7277 CacheSettings *CacheSetting
7378}
7479
@@ -81,11 +86,11 @@ type Options struct {
8186 // will be usd for all objects that have a nil Namespaces setting.
8287 //
8388 // It is possible to have specific CacheSettings for just some namespaces
84- // but cache all namespaces by using the empty string as map key for
89+ // but cache all namespaces by using the empty string as the map key for
8590 // "all namespaces". This wil then include all namespaces that do not have
8691 // a more specific setting.
8792 //
88- // If CacheSetting is nil, DefaultLabelSelector, DefaultFieldSelector
93+ // If CacheSetting is nil, DefaultLabelSelector, DefaultFieldSelector,
8994 // and DefaultTransform will be used if set.
9095 DefaultNamespaces map[string]*CacheSetting
9196
@@ -102,6 +107,47 @@ type Options struct {
102107 // DefaultUnsafeDisableDeepCopy is the default for UnsafeDisableDeepCopy
103108 // for everything that doesn't specify this.
104109 DefaultUnsafeDisableDeepCopy *bool
110+
111+ // DefaultTransform will be used as transform for all object types
112+ // unless they have a more specific transform set in ByObject.
113+ DefaultTransform toolscache.TransformFunc
114+
115+ // HTTPClient is the http client to use for the REST client
116+ HTTPClient *http.Client
117+
118+ // Scheme is the scheme to use for mapping objects to GroupVersionKinds
119+ Scheme *runtime.Scheme
120+
121+ // Mapper is the RESTMapper to use for mapping GroupVersionKinds to Resources
122+ Mapper meta.RESTMapper
123+
124+ // SyncPeriod determines the minimum frequency at which watched resources are
125+ // reconciled. A lower period will correct entropy more quickly, but reduce
126+ // responsiveness to change if there are many watched resources. Change this
127+ // value only if you know what you are doing. Defaults to 10 hours if unset.
128+ // there will a 10 percent jitter between the SyncPeriod of all controllers
129+ // so that all controllers will not send list requests simultaneously.
130+ //
131+ // This applies to all controllers.
132+ //
133+ // A period sync happens for two reasons:
134+ // 1. To insure against a bug in the controller that causes an object to not
135+ // be requeued, when it otherwise should be requeued.
136+ // 2. To insure against an unknown bug in controller-runtime, or its dependencies,
137+ // that causes an object to not be requeued, when it otherwise should be
138+ // requeued, or to be removed from the queue, when it otherwise should not
139+ // be removed.
140+ //
141+ // If you want
142+ // 1. to insure against missed watch events, or
143+ // 2. to poll services that cannot be watched,
144+ // then we recommend that, instead of changing the default period, the
145+ // controller requeue, with a constant duration `t`, whenever the controller
146+ // is "done" with an object, and would otherwise not requeue it, i.e., we
147+ // recommend the `Reconcile` function return `reconcile.Result{RequeueAfter: t}`,
148+ // instead of `reconcile.Result{}`.
149+ SyncPeriod *time.Duration
150+
105151}
106152```
107153
@@ -132,10 +178,10 @@ Options{
132178```
133179Options{
134180 ByObject: map[client.Object]*cache.ByObject{
135- &corev1.ConfgMap {}: {
181+ &corev1.ConfigMap {}: {
136182 Namespaces: map[string]*cache.CacheSetting{
137183 "": {}, // No selector for all namespaces...
138- "operator" {LabelSelector: labelSelector}, // except for the operator namespace
184+ "operator": {LabelSelector: labelSelector}, // except for the operator namespace
139185 },
140186 },
141187 },
@@ -149,7 +195,7 @@ Options{
149195Options{
150196 ByObject: map[client.Object]*cache.ByObject{
151197 &appsv1.Deployment: {Namespaces: map[string]*cacheSetting:
152- "" : {},
198+ cache.AllNamespaces : {},
153199 },
154200 },
155201 DefaultNamespaces: map[string]*cache.CacheSetting{
@@ -163,7 +209,7 @@ Options{
163209```
164210Options{
165211 ByObject: map[client.Object]*cache.ByObject{
166- &corev1.Node: {},
212+ &corev1.Node: {LabelSelector: labels.Everything() },
167213 },
168214 DefaultLabelSelector: myLabelSelector,
169215}
0 commit comments