[17.0] volumemgr: retry failed volume deletes instead of leaking them - #6205
Merged
eriknordmark merged 1 commit intoJul 22, 2026
Merged
Conversation
maybeDeleteVolume logged a failed volume delete, set the error, and
unpublished the VolumeStatus anyway ("we have no retrial mechanism for
volume delete now"). Once the status was gone volumemgr had no record of
the volume, so nothing retried and the underlying PVC/Longhorn volume was
leaked forever.
This is how a failed+retried app purge on a kubevirt/longhorn cluster
ends up with several orphaned Longhorn volumes for one app: each purge
bumps the volume generation counter, so GetPVCName() yields a new PVC
name (<VolumeID>-pvc-<gen>) and a new Longhorn volume, while the old
generation's delete was fire-and-forget and dropped on failure. For a
replicated volume the owner node being unreachable at delete time (mid
-purge, or during a node reboot for a cluster update) is enough to
trigger it. The leaked volumes keep replicating and consuming space and
don't show in the Longhorn UI (no PV/PVC/workload binding them).
On delete failure, keep the VolumeStatus published in the Deleting
sub-state with the error and re-drive it from the gc tick via
retryFailedVolumeDelete, mirroring the bounded, gc-driven pattern already
used for transient cluster-volume creates (retryclustervolume.go): a pure
volumeDeleteRetryActionFor decision function, a per-volume retry count in
an in-memory map, and give-up after maxVolumeDeleteRetries so a
permanently-undeletable volume parks terminally rather than resubmitting a
worker job forever. On give-up the volume is left published in the
Deleting sub-state with its error (like the cluster-create give-up) so an
orphaned, undeletable volume stays visible to the operator in status
instead of disappearing; it just stops being re-driven. On successful
delete, or when the volume leaves the candidate set another way (e.g. it
gets re-referenced), the retry count is cleared.
Signed-off-by: Renê de Souza Pinto <rene@renesp.com.br>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 55edeb4)
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.
Description
Backport of #6176
How to test and validate this PR
Changelog notes
Implement deletion of Longhorn orphan volumes created after failed purge operations.
Checklist
check them.