Skip to content

fix: include all failed deletions in release summaries - #2843

Merged
yxxhero merged 2 commits into
helmfile:mainfrom
spicysharkco:fix/delete-failed-releases
Oct 24, 2026
Merged

yxxhero merged 2 commits into
helmfile:mainfrom
spicysharkco:fix/delete-failed-releases

Conversation

@spicysharkco

Copy link
Copy Markdown
Contributor

Problem

With:

releases:
  - name: a-error
    chart: ./chart
  - name: b-error
    chart: ./chart

when both uninstalls fail, helmfile --no-color destroy --concurrency 1 prints:

= Failed to Delete Releases ==
NAME      NAMESPACE   DURATION
b-error                     0s

a-error is missing. sync and apply drop entries the same way for releases with installed: false, and so does a failing preuninstall or postuninstall hook.

Solution

Each failure path in DeleteReleases and DeleteReleasesForSync sets DeleteFailed to append(affectedReleases.Failed, release), so it starts again from Failed and loses the deletions that failed before. All six paths now append to DeleteFailed.

Test

TestHelmState_DeleteFailedReleases runs destroy and sync with two failing releases and one that deletes, for a failed uninstall, preuninstall hook and postuninstall hook.

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

With the fix: 6 of 6 rows pass. With the fix reverted, all 6 fail with only the second release in DeleteFailed, and reverting one line fails only its row.

@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.

Reviewed — root cause confirmed: pre-patch, each failure executed affectedReleases.DeleteFailed = append(affectedReleases.Failed, &release), overwriting DeleteFailed every time so only the last failed deletion survived, in both DeleteReleases and DeleteReleasesForSync (sync/apply path). Your change to append to DeleteFailed itself is the right accumulation.

One real issue with the new code: the accumulation is unsynchronized. DeleteReleases runs through scatterGatherReleases, and with the default concurrency (0 = one worker per release) concurrent workers append to the shared DeleteFailed/Deleted slices without a lock — a data race (-race) that can still lose entries non-deterministically, i.e. the exact bug this PR fixes can resurface under concurrency. The sibling paths (DeleteReleasesForSync, SyncReleases) already guard their appends with a mutex.

I've pushed b919ba2 to this branch:

  • adds a sync.Mutex guarding the four append sites in DeleteReleases (fine-grained lock/unlock around each append, so helm calls are not serialized),
  • adds TestHelmState_DeleteFailedReleasesConcurrently (5 failing releases, concurrency 3, order-independent ElementsMatch assertions).

CI on the new commit is running; it was fully green on 35e9e2e.

Two pre-existing, non-blocking observations:

  • SyncReleases' defensive !Desired() uninstall branch (pkg/state/state.go:1321-1339) reports delete failures under ar.Failed ("Failed Releases" table) instead of DeleteFailed — unreachable via current sync/apply flows, but a candidate for unification.
  • exectest.Helm.Deleted (pkg/exectest/helm.go:186) appends without a mutex (unlike DiffMutex/ReleasesMutex); the new test deliberately only uses failing releases so it never hits that.

@spicysharkco

Copy link
Copy Markdown
Contributor Author

Thanks for catching the race and for pushing the fix. The locking in b919ba2 matches DeleteReleasesForSync, and the delete tests pass under -race at that commit.

spicysharkco and others added 2 commits October 24, 2026 07:59
When several releases fail to uninstall, destroy, sync and apply list only
the last failure in the deletion summary.

Append to the existing deletion failures instead of the install failures
in each uninstall and hook failure path, preserving earlier entries.

Signed-off-by: spicysharkco <[email protected]>
DeleteReleases runs its per-release callback on concurrent workers
(a concurrency of 0, the default, means one worker per release), so
the appends to AffectedReleases.DeleteFailed and Deleted must be
guarded by a mutex to keep the summary complete and race-free.
Mirror the m.Lock() pattern already used by DeleteReleasesForSync
and SyncReleases, and cover it with a test that deletes multiple
failing releases with concurrency 3.

Signed-off-by: yxxhero <[email protected]>
@yxxhero
yxxhero force-pushed the fix/delete-failed-releases branch from b919ba2 to b8254b8 Compare October 23, 2026 23:59
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