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

Reduce the number of API calls to K8S #197

Merged
merged 1 commit into from
Sep 26, 2023

Conversation

javacruft
Copy link
Contributor

The charm makes a large number of API calls to retrieve information about the IP address allocated to the K8S service; cache this information to reduce the number of calls made and speed up hook performance.

Issue

Improve the performance of hook executions

Solution

Cache response from K8S to reduce the amount of API calls made.

Context

The traefik charm stands out as always the last to settle in Sunbeam deployments; hopefully this may improve this situation a bit.

Testing Instructions

https://microstack.run/docs -> "multi-node tutorial"

@javacruft
Copy link
Contributor Author

new in py39 - drat!

Let me take another run at this.

@javacruft javacruft marked this pull request as draft July 12, 2023 09:43
@PietroPasotti
Copy link
Collaborator

@javacruft seems like performance has been decreasing lately, we can consider merging this work, what's the status?

The charm makes a large number of API calls to retrieve information
about the IP address allocated to the K8S service; cache this
information to reduce the number of calls made and speed up hook
performance.

Note functools.lru_cache is used as this charm runs on 20.04 which
uses Python 3.8 - when the base is updated to 22.04 the more simple
cache decorator can be used instead.
@javacruft
Copy link
Contributor Author

@PietroPasotti refreshed for 3.8 compatibility - I'm taking it for a test drive now

Copy link
Member

@simskij simskij left a comment

Choose a reason for hiding this comment

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

Should be relatively risk-free as the charm exits after every invocation, meaning that the caching will only be done throughout the lifetime of a single event.

@PietroPasotti
Copy link
Collaborator

itests failing due to some ingress gateway unavailable

@javacruft javacruft marked this pull request as ready for review September 26, 2023 09:35
@javacruft
Copy link
Contributor Author

@PietroPasotti any idea what the cause of the gateway unavailable error is? I had a dig around in the logs but can't see anything obvious

@PietroPasotti
Copy link
Collaborator

@PietroPasotti any idea what the cause of the gateway unavailable error is? I had a dig around in the logs but can't see anything obvious

no idea either: https://discourse.charmhub.io/t/traefik-k8s-docs-troubleshooting-gateway-address-unavailable/10813

@PietroPasotti
Copy link
Collaborator

@PietroPasotti any idea what the cause of the gateway unavailable error is? I had a dig around in the logs but can't see anything obvious

't was flaky

@PietroPasotti PietroPasotti merged commit e49763e into canonical:main Sep 26, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants