-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
client.New() takes more than 10 sec when far from apiserver (apiutil.NewDiscoveryRESTMapper) #537
Comments
Maybe a fix can also take into account #321 because they are around the same code. |
Here is a function I used that in my case reduces the time from above 10 seconds to 2:
|
yes, parallel discovery, lazy discovery, and dynamic reloading of discovery would be useful. PRs definitely welcome, but be prepared for some design discussion. I'd prefer lazy discovery to explicit filters, though. |
@guymguym your approach really makes the difference. Thanks! It would be awesome to have that in the standard controller. |
This adds concurrency and optional groups filtering It also dynamically handles the case of new CRDs by running re-discover on NoMatchError
@nicolaferraro I opened a PR - lets see if it looks OK |
This adds concurrency and optional groups filtering It also dynamically handles the case of new CRDs by running re-discover on NoMatchError
Adds a discovery with concurrency and optional groups filtering. It also dynamically handles the case of new CRDs, by running re-discover on NoMatchError.
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Adds a discovery with concurrency and optional groups filtering. It also dynamically handles the case of new CRDs, by running re-discover on NoMatchError.
Adds a DynamicRESTMapperOption for discovery with groups filtering. Perhaps we can push an optional filter to discovery.DiscoveryClient which will simplify the solution.
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/lifecycle frozen |
/priority important-longterm |
Adds a DynamicRESTMapperOption for discovery with groups filtering. Perhaps we can push an optional filter to discovery.DiscoveryClient which will simplify the solution. Signed-off-by: Guy Margalit <guymguym@gmail.com>
…for NewDynamicRESTMapper() This new option provides a custom filter that is used to select only the needed api groups that the controller really needs, instead of the default discover client that will discover all the groups on the server. The motivation is since controllers typically use a fixed small number of api groups, while servers have many dynamic api groups, and in such cases if the controller has some non-zero latency to the api server, or the server is loaded, the full groups discovery can take long time (10+ seconds). The filter can reduce the number of groups drastically. We might want to consider contributing the filter option to client-go/discovery client. Signed-off-by: Guy Margalit <guymguym@gmail.com>
…for NewDynamicRESTMapper() This new option provides a custom filter that is used to select only the needed api groups that the controller really needs, instead of the default discover client that will discover all the groups on the server. The motivation is since controllers typically use a fixed small number of api groups, while servers have many dynamic api groups, and in such cases if the controller has some non-zero latency to the api server, or the server is loaded, the full groups discovery can take long time (10+ seconds). The filter can reduce the number of groups drastically. We might want to consider contributing the filter option to client-go/discovery client. Signed-off-by: Guy Margalit <guymguym@gmail.com>
…for NewDynamicRESTMapper() This new option provides a custom filter that is used to select only the needed api groups that the controller really needs, instead of the default discover client that will discover all the groups on the server. The motivation is since controllers typically use a fixed small number of api groups, while servers have many dynamic api groups, and in such cases if the controller has some non-zero latency to the api server, or the server is loaded, the full groups discovery can take long time (10+ seconds). The filter can reduce the number of groups drastically. We might want to consider contributing the filter option to client-go/discovery client. Signed-off-by: Guy Margalit <guymguym@gmail.com>
…for NewDynamicRESTMapper() This new option provides a custom filter that is used to select only the needed api groups that the controller really needs, instead of the default discover client that will discover all the groups on the server. The motivation is since controllers typically use a fixed small number of api groups, while servers have many dynamic api groups, and in such cases if the controller has some non-zero latency to the api server, or the server is loaded, the full groups discovery can take long time (10+ seconds). The filter can reduce the number of groups drastically. We might want to consider contributing the filter option to client-go/discovery client. Signed-off-by: Guy Margalit <guymguym@gmail.com>
…for NewDynamicRESTMapper() This new option provides a custom filter that is used to select only the needed api groups that the controller really needs, instead of the default discover client that will discover all the groups on the server. The motivation is since controllers typically use a fixed small number of api groups, while servers have many dynamic api groups, and in such cases if the controller has some non-zero latency to the api server, or the server is loaded, the full groups discovery can take long time (10+ seconds). The filter can reduce the number of groups drastically. We might want to consider contributing the filter option to client-go/discovery client. Signed-off-by: Guy Margalit <guymguym@gmail.com>
…for NewDynamicRESTMapper() This new option provides a custom filter that is used to select only the needed api groups that the controller really needs, instead of the default discover client that will discover all the groups on the server. The motivation is since controllers typically use a fixed small number of api groups, while servers have many dynamic api groups, and in such cases if the controller has some non-zero latency to the api server, or the server is loaded, the full groups discovery can take long time (10+ seconds). The filter can reduce the number of groups drastically. We might want to consider contributing the filter option to client-go/discovery client. Signed-off-by: Guy Margalit <guymguym@gmail.com>
In 0.15 a new dynamic and lazy RESTMapper implementation has been merged and tested, I'll go ahead and close this issue for now; if folks have more feedback or can have a reproducible test case we can have in CI that would be great to further improve our mapper. /close |
@vincepri: Closing this issue. 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. |
I am developing and running the https://github.com/noobaa/noobaa-operator as a CLI tool and remote operator for testing.
When I work with a local cluster like minikube, I don't notice anything, but when I am working to a cluster across the Atlantic, it suddenly takes long time just to initialize the client.
I wrote a short program that shows exactly where the problem is:
Any this is the output running it on a far away cluster - notice the jump of seconds on the log print times -
So it's pretty clear that with high latency network to the apiserver this loop over api groups and versions is really wasteful. we can do much better if we just run these in parallel.
I can suggest a PR to process this list with go routine workers if it sounds good to you.
Also perhaps a variant of
apiutil.NewDiscoveryRESTMapper()
that takes a filter function that can reduce the number of group-versions that will be read from the server.Perhaps there's a better way to avoid all this network-chatty initialization?
Thanks!
The text was updated successfully, but these errors were encountered: