Skip to content

Still attempt upgrades on non-deployed releases - #1043

Merged
yxxhero merged 10 commits into
helmfile:mainfrom
Secretions:PLAT-7323/jade-update-failing-tests
Nov 9, 2026
Merged

yxxhero merged 10 commits into
helmfile:mainfrom
Secretions:PLAT-7323/jade-update-failing-tests

Conversation

@JadeHayes

@JadeHayes JadeHayes commented Sep 26, 2023 •

Copy link
Copy Markdown
Contributor

Currently, if any helm release is extant in the cluster at all, "helmfile apply" will attempt to run a "helm diff" between the release in the cluster and the proposed release, and only run helm upgrade if the diff shows a change.

While this is a sensible check for "deployed" releases, for failed (and possibly any other) release states, if the diff hasn't changed (even though the release never succeded), it results in the worst possible outcome: helmfile appears to finish successfully, while completely ignoring the failed release.

This ensures we always trigger an upgrade on releases that are in a non-deployed state. This way, if re-running with the same chart would succeed, we have the opportunity to fix things on rerun (let's say a helm hook pre or post-upgrade job will succeed now due to fixing a service external to the chart); if it wouldn't, by rerunning the upgrade, we will again see the error rather than it going under the radar and giving the false impression that everything is hunky dory.

@JadeHayes
JadeHayes force-pushed the PLAT-7323/jade-update-failing-tests branch from 7b2e0b3 to 84db552 Compare September 28, 2023 18:19
@stale

stale Bot commented Oct 13, 2023

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Oct 13, 2023
@yxxhero yxxhero removed the wontfix This will not be worked on label Oct 17, 2023
@stale

stale Bot commented Nov 1, 2023

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Nov 1, 2023
@yxxhero yxxhero removed the wontfix This will not be worked on label Nov 1, 2023
@JadeHayes

Copy link
Copy Markdown
Contributor Author

Hi @yxxhero! Sorry for the delay, please let me know if theres anything more I need to do to get the workflows approved. Thank you!

@JadeHayes JadeHayes changed the title Plat 7323/jade update failing tests Still attempt upgrades on non-deployed releases Nov 10, 2023
@Secretions

Secretions commented Nov 10, 2023 •

Copy link
Copy Markdown
Contributor

Got busy after I put my PR up, so thanks @JadeHayes for finishing the swing on this!

@JadeHayes
JadeHayes marked this pull request as ready for review November 10, 2023 19:26
@JadeHayes
JadeHayes force-pushed the PLAT-7323/jade-update-failing-tests branch 2 times, most recently from 950fc7e to 3eb7b40 Compare December 7, 2023 21:06
@JadeHayes

Copy link
Copy Markdown
Contributor Author

sorry for the delay @yxxhero, got caught up in some other stuff. Thanks for your patience!

@stale

stale Bot commented Jan 4, 2024

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added wontfix This will not be worked on and removed wontfix This will not be worked on labels Jan 4, 2024
@stale

stale Bot commented Feb 2, 2024

Copy link
Copy Markdown

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale Bot added the wontfix This will not be worked on label Feb 2, 2024
@stale stale Bot closed this Feb 9, 2024
@yxxhero yxxhero reopened this Feb 14, 2024
@stale stale Bot removed the wontfix This will not be worked on label Feb 14, 2024
@Secretions
Secretions force-pushed the PLAT-7323/jade-update-failing-tests branch 3 times, most recently from 36f63f3 to 41654ad Compare February 29, 2024 00:39
@yxxhero

yxxhero commented Oct 6, 2026

Copy link
Copy Markdown
Member

Hi @JadeHayes — this PR had gone stale (last updated 2025-04, conflicting with main), so I rebased the work onto current main and force-pushed the branch (maintainer edits were enabled). The original approach and intent are preserved; main adaptations:

  • helmexec.List now returns a structured HelmReleaseOutput parsed from helm list -o yaml (your App_version field is AppVersion with an explicit yaml tag now)
  • isReleaseInstalled returns (installed, deployed, err); the diff/apply pipeline treats non-deployed (failed/pending) releases as changed even when helm-diff reports no differences, so apply reruns the upgrade instead of silently skipping
  • SkipDiffOnInstall / disable-validation logic keys on deployed rather than merely installed
  • test doubles converted from raw TSV strings to structured values, plus a regression test for failed/pending releases with empty diffs
  • the HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE path can't distinguish states and conservatively keeps the historical behavior

All code follows guard-clause style per repo convention. Letting CI validate — happy to adjust if anything looks off to you.

yxxhero added a commit to Secretions/helmfile that referenced this pull request Oct 6, 2026
Rebased onto current main; original PR helmfile#1043 by JadeHayes had gone stale
and conflicted beyond repair.

helmfile apply used to skip a release when helm-diff reported no changes,
regardless of the release state. For a release stuck in a non-deployed
state (failed, pending), rerunning apply with an unchanged chart
silently reported success while never retrying the upgrade, hiding the
failure.

- isReleaseInstalled now also reports whether the release is in the
  "deployed" state, derived from the structured helm list output
- helmexec.List returns a structured HelmReleaseOutput parsed from
  `helm list -o yaml` instead of raw tab-separated text; listReleases
  passes -o yaml
- prepareDiffReleases records the deployed state per release (cached);
  SkipDiffOnInstall and disable-validation logic now key on deployed so
  non-deployed releases take the install path
- DiffReleases reports a no-change diff on a non-deployed release as
  changed (helm-diff exit code 2) so apply reruns the upgrade
- getDeployedVersion reads the version from the structured chart field
- test doubles converted from raw TSV list output to structured values;
  new regression test covers failed/pending releases being upgraded
  despite an empty diff

The HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE path cannot
distinguish release states and conservatively reports deployed=true,
preserving its historical behavior.

Fixes helmfile#1043

Signed-off-by: yxxhero <[email protected]>
@yxxhero

yxxhero commented Oct 6, 2026

Copy link
Copy Markdown
Member

All checks are now green — unit tests (3 helm versions, race-enabled), integration tests (v3.18.6 / v3.22.0 / v4.3.0 × live-output, against real clusters), e2e, lint, builds, and DCO.

The integration goldens for diff-args and postrender were updated to reflect the new expected output: a prepare-phase Listing releases line per diffed release, and the Affected releases block for non-deployed releases reported as changed (which is the core of this PR).

@Secretions

Copy link
Copy Markdown
Contributor

Hey @yxxhero, Jade was doing this on behalf of myself (it's out of my repo). She's no longer in the same organization, so probably isn't following this, but I will take a look at this on Monday, as we'd still love to get this change in. Thanks!

@yxxhero
yxxhero force-pushed the PLAT-7323/jade-update-failing-tests branch from 0dc67c7 to 7885c44 Compare October 23, 2026 23:58
yxxhero added a commit to Secretions/helmfile that referenced this pull request Oct 23, 2026
Rebased onto current main; original PR helmfile#1043 by JadeHayes had gone stale
and conflicted beyond repair.

helmfile apply used to skip a release when helm-diff reported no changes,
regardless of the release state. For a release stuck in a non-deployed
state (failed, pending), rerunning apply with an unchanged chart
silently reported success while never retrying the upgrade, hiding the
failure.

- isReleaseInstalled now also reports whether the release is in the
  "deployed" state, derived from the structured helm list output
- helmexec.List returns a structured HelmReleaseOutput parsed from
  `helm list -o yaml` instead of raw tab-separated text; listReleases
  passes -o yaml
- prepareDiffReleases records the deployed state per release (cached);
  SkipDiffOnInstall and disable-validation logic now key on deployed so
  non-deployed releases take the install path
- DiffReleases reports a no-change diff on a non-deployed release as
  changed (helm-diff exit code 2) so apply reruns the upgrade
- getDeployedVersion reads the version from the structured chart field
- test doubles converted from raw TSV list output to structured values;
  new regression test covers failed/pending releases being upgraded
  despite an empty diff

The HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE path cannot
distinguish release states and conservatively reports deployed=true,
preserving its historical behavior.

Fixes helmfile#1043

Signed-off-by: yxxhero <[email protected]>
@yxxhero

yxxhero commented Oct 23, 2026

Copy link
Copy Markdown
Member

@Secretions sure. thanks so much.

Secretions pushed a commit to Secretions/helmfile that referenced this pull request Oct 28, 2026
Rebased onto current main; original PR helmfile#1043 by JadeHayes had gone stale
and conflicted beyond repair.

helmfile apply used to skip a release when helm-diff reported no changes,
regardless of the release state. For a release stuck in a non-deployed
state (failed, pending), rerunning apply with an unchanged chart
silently reported success while never retrying the upgrade, hiding the
failure.

- isReleaseInstalled now also reports whether the release is in the
  "deployed" state, derived from the structured helm list output
- helmexec.List returns a structured HelmReleaseOutput parsed from
  `helm list -o yaml` instead of raw tab-separated text; listReleases
  passes -o yaml
- prepareDiffReleases records the deployed state per release (cached);
  SkipDiffOnInstall and disable-validation logic now key on deployed so
  non-deployed releases take the install path
- DiffReleases reports a no-change diff on a non-deployed release as
  changed (helm-diff exit code 2) so apply reruns the upgrade
- getDeployedVersion reads the version from the structured chart field
- test doubles converted from raw TSV list output to structured values;
  new regression test covers failed/pending releases being upgraded
  despite an empty diff

The HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE path cannot
distinguish release states and conservatively reports deployed=true,
preserving its historical behavior.

Fixes helmfile#1043

Signed-off-by: yxxhero <[email protected]>
@Secretions
Secretions force-pushed the PLAT-7323/jade-update-failing-tests branch 2 times, most recently from 13b3862 to cee1675 Compare October 28, 2026 20:41
@Secretions

Copy link
Copy Markdown
Contributor

Tested the current state of this locally, and it lgtm.

@yxxhero
yxxhero force-pushed the PLAT-7323/jade-update-failing-tests branch from 0b8f3ed to 25d5614 Compare November 8, 2026 08:41
yxxhero added a commit to Secretions/helmfile that referenced this pull request Nov 8, 2026
Rebased onto current main; original PR helmfile#1043 by JadeHayes had gone stale
and conflicted beyond repair.

helmfile apply used to skip a release when helm-diff reported no changes,
regardless of the release state. For a release stuck in a non-deployed
state (failed, pending), rerunning apply with an unchanged chart
silently reported success while never retrying the upgrade, hiding the
failure.

- isReleaseInstalled now also reports whether the release is in the
  "deployed" state, derived from the structured helm list output
- helmexec.List returns a structured HelmReleaseOutput parsed from
  `helm list -o yaml` instead of raw tab-separated text; listReleases
  passes -o yaml
- prepareDiffReleases records the deployed state per release (cached);
  SkipDiffOnInstall and disable-validation logic now key on deployed so
  non-deployed releases take the install path
- DiffReleases reports a no-change diff on a non-deployed release as
  changed (helm-diff exit code 2) so apply reruns the upgrade
- getDeployedVersion reads the version from the structured chart field
- test doubles converted from raw TSV list output to structured values;
  new regression test covers failed/pending releases being upgraded
  despite an empty diff

The HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE path cannot
distinguish release states and conservatively reports deployed=true,
preserving its historical behavior.

Fixes helmfile#1043

Signed-off-by: yxxhero <[email protected]>
@yxxhero
yxxhero force-pushed the PLAT-7323/jade-update-failing-tests branch from 083d21f to 25d5614 Compare November 8, 2026 12:02
yxxhero and others added 9 commits November 9, 2026 08:19
Rebased onto current main; original PR helmfile#1043 by JadeHayes had gone stale
and conflicted beyond repair.

helmfile apply used to skip a release when helm-diff reported no changes,
regardless of the release state. For a release stuck in a non-deployed
state (failed, pending), rerunning apply with an unchanged chart
silently reported success while never retrying the upgrade, hiding the
failure.

- isReleaseInstalled now also reports whether the release is in the
  "deployed" state, derived from the structured helm list output
- helmexec.List returns a structured HelmReleaseOutput parsed from
  `helm list -o yaml` instead of raw tab-separated text; listReleases
  passes -o yaml
- prepareDiffReleases records the deployed state per release (cached);
  SkipDiffOnInstall and disable-validation logic now key on deployed so
  non-deployed releases take the install path
- DiffReleases reports a no-change diff on a non-deployed release as
  changed (helm-diff exit code 2) so apply reruns the upgrade
- getDeployedVersion reads the version from the structured chart field
- test doubles converted from raw TSV list output to structured values;
  new regression test covers failed/pending releases being upgraded
  despite an empty diff

The HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE path cannot
distinguish release states and conservatively reports deployed=true,
preserving its historical behavior.

Fixes helmfile#1043

Signed-off-by: yxxhero <[email protected]>
prepareDiffReleases now resolves the deployed state for every diffed
release, which surfaces as an extra helm list call per release. Test
tables must therefore describe the cluster state of every release:

- add absent ({}) entries for fresh-install releases (apply/diff install
  cases)
- add deployed entries for releases previously left unlisted that must
  keep the skip-on-no-change behavior (skip-needs cases, diff smoke)
- header-only TSV outputs in destroy tests meant 'release exists' under
  the old non-empty-string semantics: use deployed entries
- fix one misconverted TSV row (leading-tab indentation shifted the
  status column into an empty value)
- TestDiff_2 (no kube-context) entries must use the no-kube-context flag
  set
- snapshot for the helm-status existence-check case gains the extra
  per-release status check line
- apply golangci-lint fmt (map literal type elision) across tests

Signed-off-by: yxxhero <[email protected]>
With absent-release entries present in the Lists fixture, the
getDeployedVersion lookups now succeed with empty output and fall
through to the chart-metadata fallback, changing the logged failure
from "unexpected list key" to "Failed to get the version for".

Signed-off-by: yxxhero <[email protected]>
…rades

helmfile diff/apply now resolve the deployed state of every diffed
release, which adds a prepare-phase 'Listing releases' line for
previously-installed releases, and a no-change diff on a non-deployed
release is reported as changed (with its 'Affected releases' block) so
apply reruns the upgrade.

Signed-off-by: yxxhero <[email protected]>
Signed-off-by: Joaquin Lopez <[email protected]>
…tcode

Review fixes for the non-deployed-release handling:

- Only run the extra helm list deployed-state probe and force the
  "changed" result for non-deployed releases when the caller acts on
  diff results (helmfile apply, or diff --detailed-exitcode). A plain
  `helmfile diff` no longer lists fresh/failed-but-unchanged releases
  in "Affected releases are:" with no exit-code change, and skips the
  extra helm list I/O entirely.
- Log why a non-deployed unchanged release is treated as changed, so an
  "UPDATED" release with no diff output is no longer unexplained.
- Make ReleaseError.Error() nil-safe: the synthetic changed-release
  errors carry a nil err and would panic if ever formatted.
- Escape the chart name in the getDeployedVersion regex with
  regexp.QuoteMeta.
- Revert plain-diff integration goldens accordingly (apply goldens keep
  the new "Listing releases matching ..." line); cover the plain-diff
  no-change case in unit tests; extend CHANGELOG.

Signed-off-by: yxxhero <[email protected]>
Second review pass on 53ee70c:

- Precise the comment on the gated isDeployed probe: flag-specific
  lookups (--skip-diff-on-install and friends) still run helm list for
  plain diffs, as they predate this change.
- ReleaseError.Error() now also guards against a nil ReleaseSpec and
  no longer claims a synthetic exit code 2 ("changed") is a failure.
- The plain-diff unit test now fails on ANY unexpected helm list call
  (empty stub map + FailOnUnexpectedList), pinning down that a plain
  diff performs no deployed-state probe at all.

Verified callers of the gating: apply (always true), diff
(--detailed-exitcode flag), sync (uses diff only for the interactive
confirmation prompt and discards the changed set - sync upgrades
unconditionally), destroy (no diff).

Signed-off-by: yxxhero <[email protected]>
@yxxhero
yxxhero force-pushed the PLAT-7323/jade-update-failing-tests branch from 25d5614 to 4933fe9 Compare November 9, 2026 00:19
- CHANGELOG: note that HELMFILE_USE_HELM_STATUS_TO_CHECK_RELEASE_EXISTENCE
  keeps the previous skip-on-no-change behavior (helm status cannot
  distinguish release states)
- helmexec: List() now warns when `helm list` returns more than one
  entry for a filter, instead of silently using the first; covered by
  a new table-driven unit test (parse, empty output, multi-entry warn)
- state: quote the release name in the `helm list --filter` regex so
  names containing regex metacharacters (e.g. ".") match exactly
- state: document that diffPrepareResult.deployed is only populated
  under detailedExitCode

Signed-off-by: yxxhero <[email protected]>
@yxxhero
yxxhero force-pushed the PLAT-7323/jade-update-failing-tests branch from 1650a5f to c3750ed Compare November 9, 2026 01:04
@yxxhero
yxxhero merged commit 1874dfc into helmfile:main Nov 9, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants