@@ -176,7 +176,8 @@ func (c *CacheDelegator) Get(ctx context.Context, key string, opts storage.GetOp
176
176
}
177
177
178
178
func (c * CacheDelegator ) GetList (ctx context.Context , key string , opts storage.ListOptions , listObj runtime.Object ) error {
179
- if shouldDelegateList (opts ) {
179
+ shouldDelegate , consistentRead := shouldDelegateList (opts )
180
+ if shouldDelegate {
180
181
return c .storage .GetList (ctx , key , opts , listObj )
181
182
}
182
183
@@ -198,8 +199,6 @@ func (c *CacheDelegator) GetList(ctx context.Context, key string, opts storage.L
198
199
return c .storage .GetList (ctx , key , opts , listObj )
199
200
}
200
201
}
201
- requestWatchProgressSupported := etcdfeature .DefaultFeatureSupportChecker .Supports (storage .RequestWatchProgress )
202
- consistentRead := opts .ResourceVersion == "" && utilfeature .DefaultFeatureGate .Enabled (features .ConsistentListFromCache ) && requestWatchProgressSupported
203
202
if consistentRead {
204
203
listRV , err = c .storage .GetCurrentResourceVersion (ctx )
205
204
if err != nil {
@@ -243,31 +242,33 @@ func shouldDelegateListOnNotReadyCache(opts storage.ListOptions) bool {
243
242
// NOTICE: Keep in sync with shouldListFromStorage function in
244
243
//
245
244
// staging/src/k8s.io/apiserver/pkg/util/flowcontrol/request/list_work_estimator.go
246
- func shouldDelegateList (opts storage.ListOptions ) bool {
245
+ func shouldDelegateList (opts storage.ListOptions ) ( shouldDeletage , consistentRead bool ) {
247
246
// see https://kubernetes.io/docs/reference/using-api/api-concepts/#semantics-for-get-and-list
247
+ consistentRead = false
248
248
switch opts .ResourceVersionMatch {
249
249
case metav1 .ResourceVersionMatchExact :
250
- return true
250
+ return true , consistentRead
251
251
case metav1 .ResourceVersionMatchNotOlderThan :
252
- return false
252
+ return false , consistentRead
253
253
case "" :
254
254
// Legacy exact match
255
255
if opts .Predicate .Limit > 0 && len (opts .ResourceVersion ) > 0 && opts .ResourceVersion != "0" {
256
- return true
256
+ return true , consistentRead
257
257
}
258
258
// Continue
259
259
if len (opts .Predicate .Continue ) > 0 {
260
- return true
260
+ return true , consistentRead
261
261
}
262
262
// Consistent Read
263
263
if opts .ResourceVersion == "" {
264
+ consistentRead = true
264
265
consistentListFromCacheEnabled := utilfeature .DefaultFeatureGate .Enabled (features .ConsistentListFromCache )
265
266
requestWatchProgressSupported := etcdfeature .DefaultFeatureSupportChecker .Supports (storage .RequestWatchProgress )
266
- return ! consistentListFromCacheEnabled || ! requestWatchProgressSupported
267
+ return ! consistentListFromCacheEnabled || ! requestWatchProgressSupported , consistentRead
267
268
}
268
- return false
269
+ return false , consistentRead
269
270
default :
270
- return true
271
+ return true , consistentRead
271
272
}
272
273
}
273
274
0 commit comments