fix: don't run Sveltos templating over Helm values on chart-identity paths - #1956
Draft
AmirAliSobhGol wants to merge 1 commit into
Conversation
…paths
getInstantiatedChart instantiates every field of a HelmChart as a Sveltos
Go template, including Values. Values that are not valid Sveltos templates
(e.g. helm-style {{ .Values.x }} placeholders meant for the chart's own tpl
rendering) made instantiation fail on paths that only need the chart
identity:
- updateChartMap: the ClusterSummary never registers its charts with the
chartManager, so allMatchingProfilesProcessed never sees the profile as
processed and canUninstallHelmChart returns
WaitForProfileProcessingError forever: helm uninstall of every other
profile on the cluster is blocked.
- uninstallHelmCharts / getClusterSummaryWithInstantiatedCharts on the
undeploy path: undeploy retries the template error forever and the
ClusterSummary finalizer is never removed, wedging profile deletion.
Values are already instantiated at the point of use (install/upgrade/hash)
by getHelmChartInstantiatedValues, so instantiating them here was also a
double templating. Leave Values untouched in getInstantiatedChart and let
the deploy path surface the template error as a per-chart failure instead.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Member
|
Thanks. I see the error and the double instantiation of Values is also breaking this https://projectsveltos.io/main/template/additional_template_info/#embedding-go-templates-in-sveltos If we proceed with this I suggest renaming the getInstantiatedChart to getInstantiatedChartIdentity. |
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.
What happens
A single ClusterProfile whose
helmCharts[].valuesfail Sveltos template rendering — e.g. helm-style{{ .Values.x }}placeholders meant for the chart's owntpl— silently wedges helm lifecycle for the whole cluster:featureSummariesstays empty);Steps to reproduce (v1.14.0, kind)
kind create cluster --name mgmt, install Sveltos v1.14.0, register the management cluster itself (SveltosClustermgmt/mgmt), and label it:Apply a healthy profile:
Apply the broken profile — the values are valid for the chart but are not a valid Sveltos template (
.Valuesdoes not exist in the Sveltos template context):Wait for the prometheus release to install. Note the fluent-bit ClusterSummary shows empty
featureSummaries— no error is surfaced anywhere.kubectl delete clusterprofile fluent-bitExpected: deletion completes (or at least a visible per-chart failure).
Actual: hangs indefinitely (30+ minutes in my run); the ClusterSummary finalizer is never removed.
kubectl delete clusterprofile prometheusExpected: the prometheus release is uninstalled and the profile goes away.
Actual: the release stays installed indefinitely (17+ minutes until I deployed the fix, at which point both deletions completed on their own); the addon-controller logs repeat
ClusterProfile prometheus matches cluster mgmt/mgmt but ClusterSummary not fully processed yet.Root cause
The render error (
can't evaluate field Values in type *controllers.currentClusterObjects) comes fromgetInstantiatedChart, which runsinstantiateStructFieldsover every field of theHelmChart, includingValues. That single error wedges three paths:updateChartMap→getClusterSummaryWithInstantiatedCharts→getInstantiatedChartfails beforeRegisterClusterSummaryForChartsruns, and reconciliation of the ClusterSummary aborts there —featureSummariesstays empty, so there is no visible failure either.uninstallHelmCharts, andundeployHelmChartResources→getClusterSummaryWithInstantiatedCharts) re-runs the same instantiation, retries the error indefinitely, and the ClusterSummary finalizer is never removed.canUninstallHelmChart→allMatchingProfilesProcessed→isProfileFullyProcessedseesGetRegisteredChartsCount < len(HelmCharts)forever and returnsWaitForProfileProcessingErroron every retry — so any healthy profile deleted while the broken one exists keeps its release installed indefinitely.But
Valuesis not needed on any of these paths — chartManager registration and uninstall only need the chart identity (release name/namespace, repo, chart name/version). Meanwhile the paths that do consume values (install / upgrade / value-hash) already instantiate the rawValuesstring themselves viagetHelmChartInstantiatedValues, so instantiating them ingetInstantiatedChartalso meant values were templated twice.Fix
getInstantiatedChartsetsValuesaside beforeinstantiateStructFieldsand restores the raw string afterward. Identity fields are still templated exactly as before (the existing test templatingchartVersionfrom cluster labels still passes); values are templated exactly once, at the point of use, where a render error surfaces as a per-chart deploy failure (Helm FailedinfeatureSummaries) instead of wedging registration and undeploy.Verification
getInstantiatedChart leaves Values alone even when they are not a valid Sveltos template../controllers/envtest suite passes.Helm Failedtemplate error, and a full re-run of the scenario (deploy both → delete broken → delete healthy) completed without hangs.🤖 Generated with Claude Code