Uh oh!
There was an error while loading. Please reload this page.
opt: scope Secret/templateResourceRefs caching to cut memory - #1920
Merged
Conversation
gianlucam76force-pushed
the
secret-caching
branch
from
August 16, 2026 18:49
98bf07d to
79ac5deCompareThis PR reduces addon-controller's steady-state memory footprint 1. **templateResourceRefs/policyRefs/kustomizationRefs watcher no longer caches full objects it never reads** The dynamic watcher in clustersummary_watchers.go used a full SharedIndexInformer per referenced GVK. Replaced with a cache.Reflector backed by a discardingStore that tracks only each object's last-seen Generation not the object itself. Behavior is unchanged: consumers are still notified on Add/Update/Delete, and templateResourceRefsWatchedIgnoreStatus still skips status-only updates via the tracked Generation. 2. **Secret cache scoped to ClusterProfileSecretType, made unconditional** Only Secrets of type=addons.projectsveltos.io/cluster-profile are cached. 3. **Uncached client for all non-ClusterProfileSecretType Secret reads** With Secret cache scoping now permanent, any code path reading a Secret of a different type through the cached client would start seeing silent NotFound errors. Added getManagementClusterDirectClient(), an uncached client built once in SetManagementClusterAccess, and routed every such read through it instead: - kubeconfig Secrets for SveltosCluster and CAPI managed clusters (direct clusterproxy.GetKubernetesClient calls, and everything that goes through libsveltos/lib/clustercache's GetKubernetesRestConfig/ GetKubernetesClient/GetMapper/GetCachedDiscoveryClient, which thread the passed-in client straight through to the same kubeconfig Secret read on cache miss) - Helm registry credentials/CA Secrets (RegistryCredentialsConfig) - Helm chart version-check registry auth Secret - cosign public-key and GPG keyring Secrets for chart provenance verification 4. **Every remaining kubeconfig-Secret read now goes through clustercache, not a bare client build**
gianlucam76force-pushed
the
secret-caching
branch
from
August 17, 2026 05:57
79ac5de to
09b59f5CompareUh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR reduces addon-controller's steady-state memory footprint
templateResourceRefs/policyRefs/kustomizationRefs watcher no longer caches full objects it never reads The dynamic watcher in clustersummary_watchers.go used a full SharedIndexInformer per referenced GVK. Replaced with a cache.Reflector backed by a discardingStore that tracks only each object's last-seen Generation not the object itself. Behavior is unchanged: consumers are still notified on Add/Update/Delete, and templateResourceRefsWatchedIgnoreStatus still skips status-only updates via the tracked Generation.
Secret cache scoped to ClusterProfileSecretType, made unconditional Only Secrets of type=addons.projectsveltos.io/cluster-profile are cached.
Uncached client for all non-ClusterProfileSecretType Secret reads With Secret cache scoping now permanent, any code path reading a Secret of a different type through the cached client would start seeing silent NotFound errors. Added getManagementClusterDirectClient(), an uncached client built once in SetManagementClusterAccess, and routed every such read through it instead: - kubeconfig Secrets for SveltosCluster and CAPI managed clusters (direct clusterproxy.GetKubernetesClient calls, and everything that goes through libsveltos/lib/clustercache's GetKubernetesRestConfig/ GetKubernetesClient/GetMapper/GetCachedDiscoveryClient, which thread the passed-in client straight through to the same kubeconfig Secret read on cache miss) - Helm registry credentials/CA Secrets (RegistryCredentialsConfig) - Helm chart version-check registry auth Secret - cosign public-key and GPG keyring Secrets for chart provenance verification