1
1
Cache Options
2
2
===================
3
3
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
5
5
the future.
6
6
7
7
## Goals
@@ -13,9 +13,9 @@ the future.
13
13
14
14
## Non-Goals
15
15
16
- * Line out how the actual implementation of the cache itself will look like .
16
+ * Describe the design and implementation of the cache itself.
17
17
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
19
19
can be implemented using a "meta cache" that delegates per object and by
20
20
extending the current multi-namespace cache
21
21
* Outline any kind of timeline for when these settings will be implemented.
@@ -26,6 +26,11 @@ the future.
26
26
27
27
28
28
```
29
+
30
+ const (
31
+ AllNamespaces = corev1.NamespaceAll
32
+ )
33
+
29
34
type CacheSetting struct {
30
35
// LabelSelector specifies a label selector. A nil value allows to
31
36
// default this.
@@ -54,21 +59,21 @@ type ByObject struct {
54
59
// An empty value in this map means "No Selectors".
55
60
//
56
61
// 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.
60
65
//
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.
62
67
// An empty map prevents this.
63
68
//
64
69
// This must be unset for cluster-scoped objects.
65
70
Namespaces map[string]*CacheSetting
66
71
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 .
69
74
//
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.
72
77
CacheSettings *CacheSetting
73
78
}
74
79
@@ -81,11 +86,11 @@ type Options struct {
81
86
// will be usd for all objects that have a nil Namespaces setting.
82
87
//
83
88
// 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
85
90
// "all namespaces". This wil then include all namespaces that do not have
86
91
// a more specific setting.
87
92
//
88
- // If CacheSetting is nil, DefaultLabelSelector, DefaultFieldSelector
93
+ // If CacheSetting is nil, DefaultLabelSelector, DefaultFieldSelector,
89
94
// and DefaultTransform will be used if set.
90
95
DefaultNamespaces map[string]*CacheSetting
91
96
@@ -102,6 +107,47 @@ type Options struct {
102
107
// DefaultUnsafeDisableDeepCopy is the default for UnsafeDisableDeepCopy
103
108
// for everything that doesn't specify this.
104
109
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
+
105
151
}
106
152
```
107
153
@@ -132,10 +178,10 @@ Options{
132
178
```
133
179
Options{
134
180
ByObject: map[client.Object]*cache.ByObject{
135
- &corev1.ConfgMap {}: {
181
+ &corev1.ConfigMap {}: {
136
182
Namespaces: map[string]*cache.CacheSetting{
137
183
"": {}, // No selector for all namespaces...
138
- "operator" {LabelSelector: labelSelector}, // except for the operator namespace
184
+ "operator": {LabelSelector: labelSelector}, // except for the operator namespace
139
185
},
140
186
},
141
187
},
@@ -149,7 +195,7 @@ Options{
149
195
Options{
150
196
ByObject: map[client.Object]*cache.ByObject{
151
197
&appsv1.Deployment: {Namespaces: map[string]*cacheSetting:
152
- "" : {},
198
+ cache.AllNamespaces : {},
153
199
},
154
200
},
155
201
DefaultNamespaces: map[string]*cache.CacheSetting{
@@ -163,7 +209,7 @@ Options{
163
209
```
164
210
Options{
165
211
ByObject: map[client.Object]*cache.ByObject{
166
- &corev1.Node: {},
212
+ &corev1.Node: {LabelSelector: labels.Everything() },
167
213
},
168
214
DefaultLabelSelector: myLabelSelector,
169
215
}
0 commit comments