-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
external.Get should get from cache #1663
Comments
is there a way to finish this? |
the reason is machine controller uses DelegatingReader,who Get and List requests for unstructured types using ClientReader(request directly to apiserver) while requests for any other type of object with use the CacheReader。i fix this by using NewClientFunc options when calling func newClientFunc(cache cache.Cache, config *rest.Config, options client.Options) (client.Client, error) {
// Create the Client for Write operations.
c, err := client.New(config, options)
if err != nil {
return nil, err
}
return &client.DelegatingClient{
Reader: cache,
Writer: c,
StatusClient: c,
}, nil
}
```go |
I was about to paste the same thing, from kubernetes-sigs/controller-runtime#615 (comment) 😄 |
In the linked controller-runtime issue, they say they don't use the cache by default for unstructured objects out of concern that you might accidentally/unknowingly end up caching all the resources in a cluster, and so it's up to someone (i.e., us) to override that. Given that we're already starting shared informers for all our |
nice.. i can't believe i did not find the issue, i have been struggling whole day to fix this... |
I haven't read the whole linked issue yet, but how do we prevent caching all resources in a cluster? |
Every reconciler we create results in caching all the resources of that specific type (e.g. the In other words, we will currently cache every typed resource we use the The thing that we're missing is using the cache against unstructured types. Do we have any code that reads unstructured objects that we don't want cached? |
|
Let's file a separate issue for that? |
I like the idea of adding the caching for unstructured resources. If for some reason we end up needing to avoid caching a specific resource type in the future I think we can cross that bridge when we get there. |
/priority important-soon |
@vincepri: Please ensure the request meets the requirements listed here. If this request no longer meets these requirements, the label can be removed In response to this:
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/test-infra repository. |
What steps did you take and what happened:
i create about 60k machines in my env, but everytime cluster-api restart or relist, it tooks a long time to process the whole item, the bottleneck is machinecontroller from metrics record by prometheus
functions that took long times were dig out through add extra logs in machine controller: mainly because of external.Get func. it spend about 5 seconds every time we call it(reconcile Bootstrap and reconcileInfraStructure). client.Get() uses
unstructuredClient
to get unstructured obj, which will usedynamicResourceClient
and send request to apiserver in everyGet
action. the request speed is limited by the QPS of the client(default is 20). i scaled the qps to 200, andclient.Get()
took about 0.5s.Anything else you would like to add:
since we have list-watch external obj in cluster-api, i think external.Get func should take advantage of it and Get from the cache. it will also reduce the num of requests sent to apiserver
/kind bug
The text was updated successfully, but these errors were encountered: