Skip to content

fix: honor release kubeVersion over the detected one in diff - #2842

Merged
yxxhero merged 1 commit into
helmfile:mainfrom
spicysharkco:fix/diff-release-kubeversion
Oct 23, 2026
Merged

yxxhero merged 1 commit into
helmfile:mainfrom
spicysharkco:fix/diff-release-kubeversion

Conversation

@spicysharkco

Copy link
Copy Markdown
Contributor

Problem

With:

releases:
  - name: example
    chart: ./chart
    kubeVersion: "1.28"

and no top-level kubeVersion, helmfile diff passes the detected cluster version, 1.30.2, as --kube-version 1.30.2. The release value is dropped. With disableAutoDetectedKubeVersionForDiff: true the same release gets --kube-version 1.28, and the docs say a release kubeVersion overrides the top-level one.

Solution

The auto-detect branch took the detected version whenever one was set. It now takes it only when the release leaves kubeVersion unset, so a release without one still gets the detected version. detectKubeVersion already returns nothing when the top-level kubeVersion is set.

Test

TestHelmState_DiffFlags gets two rows: the detected version alone, and release 1.28 with detected 1.30.2.

go test ./pkg/state -run '^TestHelmState_DiffFlags$' -count=1 -p 1

With the fix: 7 of 7 rows pass. With the fix reverted, the release row fails with = [--kube-version 1.30.2], want [--kube-version 1.28] and the other 6 pass.

When the cluster version is auto-detected, helmfile diff passed it as
--kube-version even if the release sets its own kubeVersion, so the
release value was dropped. Pass the detected version only when the
release leaves kubeVersion unset, as the path with
disableAutoDetectedKubeVersionForDiff already does.

Signed-off-by: spicysharkco <[email protected]>

@yxxhero yxxhero left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Verified: since #2276 the default diff path unconditionally set kubeVersionForDiff = opt.DetectedKubeVersion, and getKubeVersion (pkg/state/state.go:4745-4755) gives the explicit parameter top priority — so a successful detection shadowed release.KubeVersion. The new guard (release.KubeVersion == "" && ...) makes the release value win even with auto-detection enabled, matching the documented "Per-release kube version overrides top-level" semantics and the existing disableAutoDetectedKubeVersionForDiff: true behavior.

Also confirmed diff is the only auto-detecting path (flagsForTemplate and the chartify path use getKubeVersion with the CLI flag only; lint passes no --kube-version), so the diff-only scope is correct. The new test fails on the parent commit (old code would emit --kube-version 1.30.2). Nothing blocking from my side.

Non-blocking notes:

  • The indirection is correct but non-obvious: when the release sets kubeVersion, kubeVersionForDiff stays "" and the value is applied later inside getKubeVersion's fallback chain. A one-line comment could help future readers.
  • disableAutoDetectedKubeVersionForDiff has no unit-test coverage anywhere in the repo (pre-existing gap, out of scope here).
  • Optional: docs/configuration.md could mention that a release kubeVersion also suppresses the auto-detected version for diff.

@yxxhero
yxxhero merged commit c1d730a into helmfile:main Oct 23, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants