-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix Cluster.refresh sometimes taking upwards of 20s #4826
Conversation
- Only read and parse the proxy config once - Reuse the AuthorizationV1Api instance for the entire refresh instead of recreating it between 32 and 302 times, this should allow for reusing sockets Signed-off-by: Sebastian Malton <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not solve the issue of slow requests when network resources are completely exhausted but still an improvement.
return this.canI({ | ||
verb: "watch", | ||
resource: "*", | ||
...customizeResource, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This option is not used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that function was only used in one place and that was within the refreshAccessibility
method above.
this.allowedNamespaces = await this.getAllowedNamespaces(); | ||
this.allowedResources = await this.getAllowedResources(); | ||
const proxyConfig = await this.getProxyKubeconfig(); | ||
const canI = this.dependencies.createAuthorizationReview(proxyConfig); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this where the optimization is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it creates the API object only once instead of dozens or hundred of times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see here where it creates it once instead of twice like the old code. Where else is the creation avoided?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The big win is from getAllowedResources
which calls canI
in a loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, right, the class member version of canI()
was creating the api each time it was called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly
Only read and parse the proxy config once
Reuse the AuthorizationV1Api instance for the entire refresh instead
of recreating it between 32 and 302 times, this should allow for
reusing sockets
Signed-off-by: Sebastian Malton [email protected]