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:
Marek Siarkowicz 2025-03-12 18:20:47 +01:00
parent caf541857f
commit a0cc02e264
2 changed files with 24 additions and 22 deletions

View File

@ -249,14 +249,12 @@ 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
}
default:
return true
}
// Continue
if len(opts.Predicate.Continue) > 0 {
return true
@ -268,6 +266,9 @@ func shouldDelegateList(opts storage.ListOptions) bool {
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
}
return false
default:
return true
}
}
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,14 +169,12 @@ 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
}
default:
return true
}
// Continue
if len(opts.Continue) > 0 {
return true
@ -188,4 +186,7 @@ func shouldListFromStorage(query url.Values, opts *metav1.ListOptions) bool {
return !consistentListFromCacheEnabled || !requestWatchProgressSupported
}
return false
default:
return true
}
}