(bug) Fix stale Helm repository cache#1691
Merged
gianlucam76 merged 1 commit intoprojectsveltos:mainfrom Apr 4, 2026
Merged
Conversation
When a ClusterProfile is updated to reference a newer Helm chart version, addon-controller reports that the version does not exist even though it is present in the repository. A controller restart is required to deploy successfully. Root cause: repoAddOrUpdate skips re-downloading the repository index when the repo is already registered in the in-memory storage variable (which persists for the lifetime of the process). As a result, LocateChart reads a stale on-disk index that does not contain the newly published version. A reactive recovery function (handleLocateChartError) existed but had two flaws: 1. It returned the error immediately after refreshing the cache, forcing the caller to wait for the next reconciliation cycle to succeed. 2. The cache refresh was gated on the error string "no chart version found for", which is only produced by non-OCI repositories — OCI repos emit a different error message and were never healed. Fix In both the install (locateLoadAndValidateChart) and upgrade (upgradeRelease) paths, when LocateChart fails, the cache is cleared via removeCachedData and the call is retried once within the same reconciliation. If the retry also fails (e.g., the version genuinely does not exist), the error is returned as before. This approach: - Remains fully reactive — the index is never re-downloaded unless LocateChart actually fails, so deployments to N clusters where the version is already cached are unaffected. - Covers both OCI and non-OCI repositories, since the fix is unconditional on the error message. - Eliminates the wasted reconciliation cycle that required a controller restart to recover.
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 free
to 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.
When a ClusterProfile is updated to reference a newer Helm chart version, addon-controller reports that the version does not exist even though it is present in the repository. A controller restart is required to deploy successfully.
Root cause: repoAddOrUpdate skips re-downloading the repository index when the repo is already registered in the in-memory storage variable (which persists for the lifetime of the process). As a result, LocateChart reads a stale on-disk index that does not contain the newly published version.
A reactive recovery function (handleLocateChartError) existed but had two flaws:
Fix
In both the install (locateLoadAndValidateChart) and upgrade (upgradeRelease) paths, when LocateChart fails, the cache is cleared via removeCachedData and the call is retried once within the same reconciliation. If the retry also fails (e.g., the version genuinely does not exist), the error is returned as before.
This approach: