@@ -785,22 +785,30 @@ func (c *Cacher) Get(ctx context.Context, key string, opts storage.GetOptions, o
785
785
//
786
786
// staging/src/k8s.io/apiserver/pkg/util/flowcontrol/request/list_work_estimator.go
787
787
func shouldDelegateList (opts storage.ListOptions ) bool {
788
- resourceVersion := opts .ResourceVersion
789
- pred := opts .Predicate
790
- match := opts .ResourceVersionMatch
791
- consistentListFromCacheEnabled := utilfeature .DefaultFeatureGate .Enabled (features .ConsistentListFromCache )
792
- requestWatchProgressSupported := etcdfeature .DefaultFeatureSupportChecker .Supports (storage .RequestWatchProgress )
793
-
794
- // Serve consistent reads from storage if ConsistentListFromCache is disabled
795
- consistentReadFromStorage := resourceVersion == "" && ! (consistentListFromCacheEnabled && requestWatchProgressSupported )
796
- // Watch cache doesn't support continuations, so serve them from etcd.
797
- hasContinuation := len (pred .Continue ) > 0
798
- // Watch cache only supports ResourceVersionMatchNotOlderThan (default).
799
788
// see https://kubernetes.io/docs/reference/using-api/api-concepts/#semantics-for-get-and-list
800
- isLegacyExactMatch := opts .Predicate .Limit > 0 && match == "" && len (resourceVersion ) > 0 && resourceVersion != "0"
801
- unsupportedMatch := match != "" && match != metav1 .ResourceVersionMatchNotOlderThan || isLegacyExactMatch
802
-
803
- return consistentReadFromStorage || hasContinuation || unsupportedMatch
789
+ switch opts .ResourceVersionMatch {
790
+ case metav1 .ResourceVersionMatchExact :
791
+ return true
792
+ case metav1 .ResourceVersionMatchNotOlderThan :
793
+ case "" :
794
+ // Legacy exact match
795
+ if opts .Predicate .Limit > 0 && len (opts .ResourceVersion ) > 0 && opts .ResourceVersion != "0" {
796
+ return true
797
+ }
798
+ default :
799
+ return true
800
+ }
801
+ // Continue
802
+ if len (opts .Predicate .Continue ) > 0 {
803
+ return true
804
+ }
805
+ // Consistent Read
806
+ if opts .ResourceVersion == "" {
807
+ consistentListFromCacheEnabled := utilfeature .DefaultFeatureGate .Enabled (features .ConsistentListFromCache )
808
+ requestWatchProgressSupported := etcdfeature .DefaultFeatureSupportChecker .Supports (storage .RequestWatchProgress )
809
+ return ! consistentListFromCacheEnabled || ! requestWatchProgressSupported
810
+ }
811
+ return false
804
812
}
805
813
806
814
// computeListLimit determines whether the cacher should
0 commit comments