New K8s clients provider for Helm plugin #5358
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Rafa Castelblanque rcastelblanq@vmware.com
Description of the change
This PR adds a new logic for obtaining the clients for K8s APIs. It resides in the
/pkg
package, but it is only applied to the Helm plugin by now.It should speed up the response times for Helm plugin: a lot when using Pinniped, not so much without Pinniped.
Problem solved here was found to be the root cause for #4919.
In the business logic of Helm plugin (at least), usually only one type of client is required per scenario (e.g. the typed client when retrieving available packages summary).
When using the old client getter, all types of clients were being retrieved due to the invocation of
clientGetterHelper
, even if only one was needed.It turns out that when creating the dynamic client, many requests are done at the same time to the K8s APIs to get the resources, which probably is triggering the throttling mechanism. There is no throttling when
pinniped-proxy
is not in the picture, but when it is, all requests go through it, with throttling. List of URLs invoked:When creating all clients, even if only one was needed, the mentioned URLs are retrieved more than once, accumulating delays.
With this PR, the new clients provider allows to independently create the client according to the needs. All clients can still be retrieved together with
ClientProviderInterface.GetClients
, but there are dedicated methods for each type.Difference with previous implementation is that the function building the clients does not return the instances, but returns functions for each one to be invoked if needed.
Benefits
Response time in many calls is improved from 5-9 seconds down to <1s when using Pinniped and Helm plugin.
Possible drawbacks
N/A
Applicable issues