Merge pull request #130752 from serathius/watchcache-simplify-delagate

Simplify shouldDelegateList
This commit is contained in:
Kubernetes Prow Robot 2025-03-13 02:57:57 -07:00 committed by GitHub
commit 2e9bb32ee8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 22 deletions

View File

@ -249,25 +249,26 @@ func shouldDelegateList(opts storage.ListOptions) bool {
case metav1.ResourceVersionMatchExact:
return true
case metav1.ResourceVersionMatchNotOlderThan:
return false
case "":
// Legacy exact match
if opts.Predicate.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
return true
}
// Continue
if len(opts.Predicate.Continue) > 0 {
return true
}
// Consistent Read
if opts.ResourceVersion == "" {
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
}
return false
default:
return true
}
// Continue
if len(opts.Predicate.Continue) > 0 {
return true
}
// Consistent Read
if opts.ResourceVersion == "" {
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
}
return false
}
func (c *CacheDelegator) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool, preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error {

View File

@ -169,23 +169,24 @@ func shouldListFromStorage(query url.Values, opts *metav1.ListOptions) bool {
case metav1.ResourceVersionMatchExact:
return true
case metav1.ResourceVersionMatchNotOlderThan:
return false
case "":
// Legacy exact match
if opts.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
return true
}
// Continue
if len(opts.Continue) > 0 {
return true
}
// Consistent Read
if opts.ResourceVersion == "" {
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
}
return false
default:
return true
}
// Continue
if len(opts.Continue) > 0 {
return true
}
// Consistent Read
if opts.ResourceVersion == "" {
consistentListFromCacheEnabled := utilfeature.DefaultFeatureGate.Enabled(features.ConsistentListFromCache)
requestWatchProgressSupported := etcdfeature.DefaultFeatureSupportChecker.Supports(storage.RequestWatchProgress)
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
}
return false
}