kubernetes/kubernetes

when apiserver cache is not ready, the List request with resourceVersion=0 fetch data from the apiserver cache

olderTaoist opened this issue · 5 comments

What would you like to be added?

when apiserver cache is not ready, the List request with resourceVersion=0 fetch data from the apiserver cache, don't directly obtain from etcd.

staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go

func (c *Cacher) GetList(ctx context.Context, key string, opts storage.ListOptions, listObj runtime.Object) error {
	recursive := opts.Recursive
	resourceVersion := opts.ResourceVersion
	pred := opts.Predicate
	if shouldDelegateList(opts) {
		return c.storage.GetList(ctx, key, opts, listObj)
	}

	listRV, err := c.versioner.ParseResourceVersion(resourceVersion)
	if err != nil {
		return err
	}
	if listRV == 0 && !c.ready.check() {
		// If Cacher is not yet initialized and we don't require any specific
		// minimal resource version, simply forward the request to storage.
		return c.storage.GetList(ctx, key, opts, listObj)
	}
}

Why is this needed?

In our cluster, the number of some resources like pods are very large(300k+), the number of node is 7k+. the apiserver cache sometime accumulating lag, the kubelet List request of get pod directly obtain from etcd. It consumes lots of cpu & memory that's not expected. i want List request to fetch data from the apiserver cache like ConsistentListFromCache feature gate

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

/sig api-machinery
/cc @wojtek-t @serathius