From 072858c0ccde931edb8768c3655da792739a8418 Mon Sep 17 00:00:00 2001 From: Phan Le Date: Tue, 11 Jul 2023 12:37:49 -0700 Subject: [PATCH] Fix bug: if the snapshot is no longer in engine CR, don't block the removal process Longhorn-6298 Signed-off-by: Phan Le (cherry picked from commit a5b67e5ec57ec38be0d50cdbe77428d924f1b2fb) --- controller/snapshot_controller.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/controller/snapshot_controller.go b/controller/snapshot_controller.go index e46bd2cabf..86e1635766 100644 --- a/controller/snapshot_controller.go +++ b/controller/snapshot_controller.go @@ -335,7 +335,8 @@ func (sc *SnapshotController) reconcile(snapshotName string) (err error) { } }() - if _, ok := snapshot.Status.Children["volume-head"]; ok && snapshot.Status.MarkRemoved { + _, snapshotExistInEngineCR := engine.Status.Snapshots[snapshot.Name] + if _, hasVolumeHeadChild := snapshot.Status.Children["volume-head"]; snapshotExistInEngineCR && hasVolumeHeadChild && snapshot.Status.MarkRemoved { // This snapshot is the parent of volume-head, so it cannot be purged immediately. // We do not want to keep the volume stuck in attached state. return sc.handleAttachmentTicketDeletion(snapshot)