Skip to content

fix: clustercache GetKubernetesClient reuses one client per cluster - #710

Merged
gianlucam76 merged 1 commit into
projectsveltos:mainfrom
serhiimazurok:fix/clustercache-cache-client
Oct 27, 2026
Merged

gianlucam76 merged 1 commit into
projectsveltos:mainfrom
serhiimazurok:fix/clustercache-cache-client

Conversation

@serhiimazurok

Copy link
Copy Markdown
Contributor

GetKubernetesClient only caches the rest.Config and calls client.New every time. Every new client builds its own RESTMapper, so each call runs discovery again (/api + /apis). On a management cluster with a lot of CRDs that adds up fast, the classifier was doing it every 10s.

This caches the client per cluster and drops it whenever the rest.Config is dropped. The controller-runtime mapper reloads on NoMatch, so CRDs created later still work (added a test for it).

Tested with classifier v1.16.0 built on top of this, discovery calls from the report loop are gone.

@gianlucam76

gianlucam76 commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Thanks for this @serhiimazurok . The cost is real. I measured it on a kind management cluster with one managed cluster, with --v=6 on addon-controller and event-manager. In steady state, with all profiles Provisioned, each periodic collector makes 24 discovery calls per minute (GET /api and GET /apis) for 12 real calls.

I'll run few more tests in addon-controller and event-manager (replacing libsveltos with your branch). After that we can merge this. thank you.

@gianlucam76
gianlucam76 merged commit 43c9158 into projectsveltos:main Oct 27, 2026
4 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.

2 participants