-
Notifications
You must be signed in to change notification settings - Fork 22
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
Introduce a nutanix prism client cache #425
Conversation
Skipping CI for Draft Pull Request. |
3b7d552
to
3b4e896
Compare
1a67a10
to
5bdcd7c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-v1.2 #425 +/- ##
===============================================
- Coverage 9.62% 8.57% -1.05%
===============================================
Files 10 22 +12
Lines 1340 2017 +677
===============================================
+ Hits 129 173 +44
- Misses 1211 1844 +633 ☔ View full report in Codecov by Sentry. |
479da10
to
2044556
Compare
62f4c24
to
519b8f4
Compare
/retest |
The cache stores a prismgoclient.V3 client instance for each NutanixCluster instance. The cache is shared between nutanixcluster and nutanixmachine controllers.
7be47a4
to
f3adaa1
Compare
/retest |
f3adaa1
to
0663761
Compare
/retest |
This is to ensure newer versions of interfaces from SharedIndexInformers don't cause compile failures. Update go version to v1.22 becasue cmp.Or is only available in go v1.22 update prism-go-client
0663761
to
88bb02f
Compare
✅ None of your dependencies violate policy! |
/retest |
Closed in favor of #430 |
During a recent incident, it was observed that creating a new Nutanix client for each request implies basic authentication for every request. This places unnecessary stress on IAM services. This stress was particularly problematic when the IAM services were already in a degraded state, thereby prolonging recovery efforts. Each basic auth request gets processed through the entire IAM stack, significantly increasing the load and impacting performance.
It's recommend that the client use session-auth cookies instead of basic auth for requests to Prism Central where possible. Given how the CAPX controller works currently, a new client is created per reconcile cycle. In #418 we switched to using Session-Auth instead of Basic-Auth. However, switching from Basic-Auth to Session-Auth alone wouldn’t solve the problem of consistent Basic-Auth calls. This is because each time a client is created, which is every reconcile cycle, it will still result in one Basic-Auth call to
/users/me
to fetch the session cookie. To alleviate this, we are adding a cache of clients and reusing the client from the cache across reconciliation cycles of the same cluster for both the NutanixCluster and NutanixMachine reconciliation.In a large-scale setup of 40+ clusters w/ 4 nodes each, we were able to see a noticeable drop in QPS to the IAM stack for the
oidc/token
calls. Before the client caching, a controller restart led to 10+ QPS onoidc/token
endpoint with a steady state at around 0.5 QPS. After deploying the client cache changes, we saw a peak of ~3 QPS as caches warmed up and dropped to 0 QPS afterwards with sporadic requests only when session token refresh was needed. As we can see, with the changes proposed in this document, we were able to reduce the number of high-impact calls to IAM significantly.