Skip to content

Commit 2e9bb32

Browse files
authored
Merge pull request kubernetes#130752 from serathius/watchcache-simplify-delagate
Simplify shouldDelegateList
2 parents 953b40b + a0cc02e commit 2e9bb32

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

staging/src/k8s.io/apiserver/pkg/storage/cacher/delegator.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,26 @@ func shouldDelegateList(opts storage.ListOptions) bool {
249249
case metav1.ResourceVersionMatchExact:
250250
return true
251251
case metav1.ResourceVersionMatchNotOlderThan:
252+
return false
252253
case "":
253254
// Legacy exact match
254255
if opts.Predicate.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
255256
return true
256257
}
258+
// Continue
259+
if len(opts.Predicate.Continue) > 0 {
260+
return true
261+
}
262+
// Consistent Read
263+
if opts.ResourceVersion == "" {
264+
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
265+
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
266+
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
267+
}
268+
return false
257269
default:
258270
return true
259271
}
260-
// Continue
261-
if len(opts.Predicate.Continue) > 0 {
262-
return true
263-
}
264-
// Consistent Read
265-
if opts.ResourceVersion == "" {
266-
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
267-
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
268-
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
269-
}
270-
return false
271272
}
272273

273274
func (c *CacheDelegator) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool, preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error {

staging/src/k8s.io/apiserver/pkg/util/flowcontrol/request/list_work_estimator.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,23 +169,24 @@ func shouldListFromStorage(query url.Values, opts *metav1.ListOptions) bool {
169169
case metav1.ResourceVersionMatchExact:
170170
return true
171171
case metav1.ResourceVersionMatchNotOlderThan:
172+
return false
172173
case "":
173174
// Legacy exact match
174175
if opts.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
175176
return true
176177
}
178+
// Continue
179+
if len(opts.Continue) > 0 {
180+
return true
181+
}
182+
// Consistent Read
183+
if opts.ResourceVersion == "" {
184+
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
185+
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
186+
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
187+
}
188+
return false
177189
default:
178190
return true
179191
}
180-
// Continue
181-
if len(opts.Continue) > 0 {
182-
return true
183-
}
184-
// Consistent Read
185-
if opts.ResourceVersion == "" {
186-
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
187-
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
188-
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
189-
}
190-
return false
191192
}

0 commit comments

Comments
 (0)