Preserve Helm release values on rad upgrade kubernetes (#11218)#12029
Preserve Helm release values on rad upgrade kubernetes (#11218)#12029nicolejms wants to merge 18 commits into
rad upgrade kubernetes (#11218)#12029Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR fixes rad upgrade kubernetes overwriting previously stored Helm release values by separating chart defaults from CLI-provided overrides and enabling Helm “reset-then-reuse-values” behavior by default, with an explicit --reset-values opt-out.
Changes:
- Parse
--set/--set-fileinto a freshvalsmap (no longer mutatinghelmChart.Values) and passvalsinto Helm install/upgrade calls. - Default upgrades to
ResetThenReuseValuessemantics (preserve previously stored user overrides while picking up new chart defaults), with--reset-valuesto discard stored values. - Apply the same “defaults vs overrides” separation for the Contour chart; update mocks and tests for the new Helm client signatures/behavior.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/helm/radius.go | Returns a separate user-values map parsed from CLI instead of mutating chart defaults. |
| pkg/cli/helm/helmclient.go | Extends HelmClient install/upgrade APIs to accept vals and a reuseValues toggle; sets ResetThenReuseValues. |
| pkg/cli/helm/helmaction.go | Threads vals into install/upgrade and defaults reinstall upgrades to reuse prior stored values. |
| pkg/cli/helm/cluster.go | Adds ResetValues option, plumbs it through upgrade logic, and passes per-invocation vals maps. |
| pkg/cli/cmd/upgrade/kubernetes/kubernetes.go | Adds --reset-values flag and documents the new default upgrade value-preservation behavior. |
| pkg/cli/helm/contour.go | Builds a fresh Contour override map (no chart mutation) for HostNetwork-related settings. |
| pkg/cli/helm/contour_test.go | Updates tests to validate the new buildContourValues behavior. |
| pkg/cli/helm/helmaction_test.go | Updates tests for the new CLI-values parsing helper and adds a regression test (see review comment). |
| pkg/cli/helm/cluster_test.go | Updates mocks/expectations and adds coverage for the --reset-values behavior. |
| pkg/cli/helm/mock_helmclient.go | Regenerated mock to match updated HelmClient method signatures. |
| pkg/cli/helm/mock_cluster.go | Regenerated mock (parameter naming/marker field updates). |
Files not reviewed (2)
- pkg/cli/helm/mock_cluster.go: Language not supported
- pkg/cli/helm/mock_helmclient.go: Language not supported
37044f3 to
651acf5
Compare
Unit Tests 2 files ± 0 440 suites ±0 7m 22s ⏱️ -12s Results for commit ce92325. ± Comparison against base commit 0fb202f. This pull request removes 5 and adds 21 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #12029 +/- ##
==========================================
+ Coverage 52.49% 52.58% +0.09%
==========================================
Files 737 737
Lines 47269 47274 +5
==========================================
+ Hits 24813 24859 +46
+ Misses 20089 20071 -18
+ Partials 2367 2344 -23 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@copilot add dev unit tests to bring code coverage too 100% for the changes |
Added comprehensive unit tests in commit
The only uncovered lines are either OS-gated ( |
willdavsmith
left a comment
There was a problem hiding this comment.
looking pretty good. left a couple of comments/questions
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Nicole James <101607760+nicolejms@users.noreply.github.com>
Signed-off-by: Nicole James <101607760+nicolejms@users.noreply.github.com>
|
@copilot there's a regression in the helm client mock please fix it. |
Co-authored-by: nicolejms <101607760+nicolejms@users.noreply.github.com>
Head branch was pushed to by a user without write access
Fixed in 0be898d by regenerating |
|
@copilot attempt to fix the failing tests |
Co-authored-by: nicolejms <101607760+nicolejms@users.noreply.github.com>
Head branch was pushed to by a user without write access
Fixed in dfc69ba. I investigated the failing workflow logs and found |
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
Description
rad upgrade kuberneteswas passingchart defaults + current --set argstohelm upgradewith no reuse flags, so any previously-stored user values (e.g.global.azureWorkloadIdentity.enabled=true,database.enabled=true) were silently reset to chart defaults on every upgrade.Root cause
pkg/cli/helm/radius.go::addArgsFromCLIparsed--set/--set-filedirectly intohelmChart.Values, mutating the chart-default tree.pkg/cli/helm/helmclient.go::RunHelmUpgradecalledupgradeClient.Run(name, chart, helmChart.Values)without setting anyReuseValues/ResetThenReuseValues. With no reuse flag, Helm treats the passed map as the complete user-supplied override set and discards anything stored on the previous release.Fix
helmChart.Valuesfrom--set/--set-file. Parse user overrides into a separatemap[string]anyand pass them to Helm asvals.upgradeClient.ResetThenReuseValues = trueso Helm starts from the new chart defaults, overlays the user-supplied values stored on the previous release, and then overlays thevalsfrom this upgrade — exactly the semantics requested in the issue. See the Helm upgrade docs for details on--reset-then-reuse-valuesbehavior.--reset-valuesflag onrad upgrade kubernetesas the explicit opt-out (mirrors thehelmCLI escape hatch).HostNetworkno longer pollutes stored release values.Behavioral notes
helmChart.Valuesas "user-supplied values". On the first upgrade after the fix, those previously-polluted values are replayed once. From the next upgrade onward the stored user values are clean. This matcheshelm upgrade --reuse-valuessemantics and is the right trade-off (preserves user intent, no surprise resets).--reset-values.Tests
Test_prepareRadiusChart_DoesNotMutateChartValuesas a regression guard — callsprepareRadiusChartwith a mockedHelmClientreturning a chart with non-emptyValues, asserts (1) the returnedvalscontains the CLI overrides and (2)helmChart.Valuesremains unchanged.Test_Helm_UpgradeRadius_ResetValuesto verify that--reset-valuesflipsreuseValuestofalseon the helm client call.Test_parseUserValuesFromCLI_InvalidSetArg,Test_parseUserValuesFromCLI_InvalidSetFileArg,Test_parseUserValuesFromCLI_EmptyArgs— error and edge-case paths for CLI value parsing.Test_prepareRadiusChart_LoadChartError,Test_prepareRadiusChart_ParseValuesError— error paths in chart preparation.Test_prepareContourChart_LoadChartError,Test_prepareContourChart_DoesNotMutateChartValues— Contour chart error path and immutability assertion.Test_ApplyHelmChart_InstallError,Test_ApplyHelmChart_ReinstallPath,Test_ApplyHelmChart_ReinstallError,Test_ApplyHelmChart_AlreadyInstalled_NoReinstall,Test_ApplyHelmChart_QueryReleaseError— full coverage of install/reinstall/no-op/error paths.Test_PopulateDefaultClusterOptions_ContourOverrides— Contour option override branches.Test_Helm_UpgradeRadius_RadiusUpgradeError,Test_Helm_UpgradeRadius_ContourUpgradeError,Test_Helm_UpgradeRadius_CheckInstallError— upgrade error paths.valsandreuseValuesparameters.go test ./pkg/cli/helm/...andgo test ./pkg/cli/cmd/upgrade/kubernetes/...pass.Type of change
Fixes: #11218
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
eng/design-notes/in this repository, if new APIs are being introduced.