Skip to content
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

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

Nokel81
Copy link
Collaborator

@Nokel81 Nokel81 commented Feb 4, 2022

  • 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]

- 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]>
@Nokel81 Nokel81 added the bug Something isn't working label Feb 4, 2022
@Nokel81 Nokel81 added this to the 5.4.0 milestone Feb 4, 2022
@Nokel81 Nokel81 requested a review from jakolehm February 4, 2022 21:45
@Nokel81 Nokel81 requested a review from a team as a code owner February 4, 2022 21:45
@Nokel81 Nokel81 requested review from Iku-turso and removed request for a team February 4, 2022 21:45
Copy link
Contributor

@jakolehm jakolehm left a 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,
Copy link
Contributor

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?

Copy link
Collaborator Author

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);
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly

@jakolehm jakolehm merged commit 0745f9c into master Feb 8, 2022
@jakolehm jakolehm deleted the optimize-cluster-refresh branch February 8, 2022 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants