Repository navigation
fix: include all failed deletions in release summaries - #2843
Conversation
yxxhero
left a comment
There was a problem hiding this comment.
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.Mutexguarding the four append sites inDeleteReleases(fine-grained lock/unlock around each append, so helm calls are not serialized), - adds
TestHelmState_DeleteFailedReleasesConcurrently(5 failing releases, concurrency 3, order-independentElementsMatchassertions).
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 underar.Failed("Failed Releases" table) instead ofDeleteFailed— unreachable via current sync/apply flows, but a candidate for unification.exectest.Helm.Deleted(pkg/exectest/helm.go:186) appends without a mutex (unlikeDiffMutex/ReleasesMutex); the new test deliberately only uses failing releases so it never hits that.
|
Thanks for catching the race and for pushing the fix. The locking in b919ba2 matches |
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]>
b919ba2 to
b8254b8
Compare
Problem
With:
when both uninstalls fail,
helmfile --no-color destroy --concurrency 1prints:a-erroris missing.syncandapplydrop entries the same way for releases withinstalled: false, and so does a failingpreuninstallorpostuninstallhook.Solution
Each failure path in
DeleteReleasesandDeleteReleasesForSyncsetsDeleteFailedtoappend(affectedReleases.Failed, release), so it starts again fromFailedand loses the deletions that failed before. All six paths now append toDeleteFailed.Test
TestHelmState_DeleteFailedReleasesruns destroy and sync with two failing releases and one that deletes, for a failed uninstall,preuninstallhook andpostuninstallhook.go test ./pkg/state -run '^TestHelmState_DeleteFailedReleases$' -count=1 -p 1With 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.