mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 01:06:27 +00:00
Simplify shouldDelegateList
When ResourceVersionMatch is set to NotOlderThan, there is no need to handle continue or resourceVersion="". The validation in apimachinery will not pass and return: * "resourceVersionMatch is forbidden when continue is provided" * "resourceVersionMatch is forbidden unless resourceVersion is provided"
This commit is contained in:
parent
caf541857f
commit
a0cc02e264
@ -249,25 +249,26 @@ func shouldDelegateList(opts storage.ListOptions) bool {
|
|||||||
case metav1.ResourceVersionMatchExact:
|
case metav1.ResourceVersionMatchExact:
|
||||||
return true
|
return true
|
||||||
case metav1.ResourceVersionMatchNotOlderThan:
|
case metav1.ResourceVersionMatchNotOlderThan:
|
||||||
|
return false
|
||||||
case "":
|
case "":
|
||||||
// Legacy exact match
|
// Legacy exact match
|
||||||
if opts.Predicate.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
|
if opts.Predicate.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
|
||||||
return true
|
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:
|
default:
|
||||||
return true
|
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 {
|
func (c *CacheDelegator) GuaranteedUpdate(ctx context.Context, key string, destination runtime.Object, ignoreNotFound bool, preconditions *storage.Preconditions, tryUpdate storage.UpdateFunc, cachedExistingObject runtime.Object) error {
|
||||||
|
@ -169,23 +169,24 @@ func shouldListFromStorage(query url.Values, opts *metav1.ListOptions) bool {
|
|||||||
case metav1.ResourceVersionMatchExact:
|
case metav1.ResourceVersionMatchExact:
|
||||||
return true
|
return true
|
||||||
case metav1.ResourceVersionMatchNotOlderThan:
|
case metav1.ResourceVersionMatchNotOlderThan:
|
||||||
|
return false
|
||||||
case "":
|
case "":
|
||||||
// Legacy exact match
|
// Legacy exact match
|
||||||
if opts.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
|
if opts.Limit > 0 && len(opts.ResourceVersion) > 0 && opts.ResourceVersion != "0" {
|
||||||
return true
|
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:
|
default:
|
||||||
return true
|
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
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user