mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Use watch cache when rv=0 even when limit is set
This commit is contained in:
parent
ac8808b792
commit
6a76931e2c
@ -473,10 +473,15 @@ func (c *Cacher) GetToList(ctx context.Context, key string, resourceVersion stri
|
|||||||
// Implements storage.Interface.
|
// Implements storage.Interface.
|
||||||
func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, pred SelectionPredicate, listObj runtime.Object) error {
|
func (c *Cacher) List(ctx context.Context, key string, resourceVersion string, pred SelectionPredicate, listObj runtime.Object) error {
|
||||||
pagingEnabled := utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking)
|
pagingEnabled := utilfeature.DefaultFeatureGate.Enabled(features.APIListChunking)
|
||||||
if resourceVersion == "" || (pagingEnabled && (len(pred.Continue) > 0 || pred.Limit > 0)) {
|
hasContinuation := pagingEnabled && len(pred.Continue) > 0
|
||||||
|
hasLimit := pagingEnabled && pred.Limit > 0 && resourceVersion != "0"
|
||||||
|
if resourceVersion == "" || hasContinuation || hasLimit {
|
||||||
// If resourceVersion is not specified, serve it from underlying
|
// If resourceVersion is not specified, serve it from underlying
|
||||||
// storage (for backward compatibility). If a continuation or limit is
|
// storage (for backward compatibility). If a continuation is
|
||||||
// requested, serve it from the underlying storage as well.
|
// requested, serve it from the underlying storage as well.
|
||||||
|
// Limits are only sent to storage when resourceVersion is non-zero
|
||||||
|
// since the watch cache isn't able to perform continuations, and
|
||||||
|
// limits are ignored when resource version is zero.
|
||||||
return c.storage.List(ctx, key, resourceVersion, pred, listObj)
|
return c.storage.List(ctx, key, resourceVersion, pred, listObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user