Repository navigation
fix: reuse only user-supplied values when no values flag is given (#464) - #1087
Merged
yxxhero merged 3 commits intoOct 18, 2026
Merged
Conversation
…tabus23#464) Without any --set/--values flag, helm-diff fetched the values of the release with `helm get values --all` and passed them to the render command as --values. That output contains the whole values.yaml of the chart the release was installed from, and a --values file takes precedence over the values.yaml of the new chart. Changes to the chart's own values.yaml were therefore missing from the diff. `helm upgrade` only does that with --reuse-values. By default it reuses just the user-supplied values of the release. Fetch the values without --all in that case, and pass no --values at all when the release has no user-supplied values (`helm get values` prints "null" then). The diff for --reuse-values and --reset-then-reuse-values does not change.
…production Complete the review of databus23#1087 ("reuse only user-supplied values when no values flag is given"): - Fill the remaining gaps of the flag matrix in TestUpgradeCommand_Execution_ReuseValues: an existing release with --set or --reset-values must not fetch the release values at all (Helm reuses them only when no new values are given), --reuse-values with --set must keep fetching with --all, and --reset-then-reuse-values on a release without user-supplied values must skip --values like the default path. The last case fails on master; the others pin behavior the fix must not regress. - Pin the new HELM_DIFF_FAKE_VALUES_OUTPUT branch of the fake helm, including the set-but-empty case that os.LookupEnv makes possible. - Add scripts/issues/464.sh, the end-to-end reproduction of databus23#464 for the CI integration job (scripts/issues/run.sh picks it up automatically): a chart default change must be visible in the default diff, a user-supplied value must win over a changed default, --reuse-values keeps the old chart values, and --set replaces the release values. The unit tests cannot assert rendered values because the fake helm echoes a fixed manifest. Signed-off-by: yxxhero <aiopsclub@163.com>
The reproduction installs two releases of the same chart into one namespace, which made both render the same ConfigMap cm. Helm 3.18+ and v4 refuse to import a resource another release owns, so the rel2 install aborted with an ownership validation error before any scenario ran. Name the ConfigMap after the release so each release owns its own object; the scenario assertions only match data lines and do not care. Signed-off-by: yxxhero <aiopsclub@163.com>
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.
Fixes #464
helm diff upgradewithout any--set/--valuesflag does not show changes made to the chart's ownvalues.yaml. For a release installed from a local chart, editing a value invalues.yamlgives an empty diff, whilehelm upgradedoes apply the change.Cause
When no value flag is given,
template()incmd/helm.gofetches the values of the release withhelm get values --alland passes them tohelm templateas--values. With--allthat output is the fully coalesced values, so it contains the wholevalues.yamlof the chart the release was installed from. A--valuesfile takes precedence over thevalues.yamlof the new chart, so every changed default is overridden by its old value. (The root cause was worked out by @antoineozenne in the issue.)This is what
helm upgrade --reuse-valuesdoes, not whathelm upgradedoes by default. InreuseValues()the default case is only:current.Configholds the user-supplied values. The chart's values are left alone.Fix
Without
--reuse-values, fetch the values without--all, which iscurrent.Config. If the release has no user-supplied values,helm get valuesprintsnull, and no--valuesis passed at all.--reuse-valuesstill uses--all, and--reset-then-reuse-valuesalready fetched without--all. The same code runs withHELM_DIFF_USE_UPGRADE_DRY_RUN=true, so that mode is fixed too.Behaviour change
The default diff now includes changes to the chart's default values. A diff that used to be empty can now show changes, and
--detailed-exitcodethen returns 2 for it. Those are the changeshelm upgrademakes. User-supplied values of the release are still kept, as before.Tests
TestUpgradeCommand_Execution_ReuseValues: the case "existing release without value flags" from fix: skip --reuse-values for a release that is not installed (#481) #1086 expectedhelm get values --all. It now expects the call without--all, since that expectation was this bug. Two new cases coverHELM_DIFF_USE_UPGRADE_DRY_RUNand a release without user-supplied values, wherehelm get valuesprintsnulland no--valuesmay be passed. All cases now also check whether--valuesreaches the render command. The three default-path cases fail on master. The fake helm can print a separate output forhelm get valuesthroughHELM_DIFF_FAKE_VALUES_OUTPUT.--set user=from-install, then changed a default invalues.yamland added a new key. For each row I comparedhelm diff upgradewithhelm upgrade --dry-run=server:HELM_DIFF_USE_UPGRADE_DRY_RUN=true--reset-values--reset-then-reuse-values-f extra.yaml--reuse-valuesBoth Helm versions give the same results. Only the two rows without flags change. With only an existing value edited,
helm diff upgrade --allow-unreleasedprints an empty diff on master and the changed line with this PR.make format,make lintandmake testpass, and golangci-lint v2.14.0 reports 0 issues.Not tested: a kind cluster, so the CI integration job has not been run locally. I did not add a
scripts/issues/464.sh; I can add one if you want it.Not part of this PR
--reuse-values, a key that is new in the chart'svalues.yamlstill appears in the diff, because a--valuesfile can only be merged over the new chart's values and Helm replaces them.HELM_DIFF_USE_UPGRADE_DRY_RUN=true,--reset-valuesis not passed on tohelm upgrade, so a release with user-supplied values keeps them in the diff. That is the same before and after this change.