Skip to content

Commit 8edb44f

Browse files
committed
fix: allow deleting orphans while retaining the data
check for DeleteCustomResourceOnly label in orphan if label is set to true, skip data cleaning ref#11286 Signed-off-by: Nina Zhan <[email protected]>
1 parent ed5c43f commit 8edb44f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

controller/orphan_controller.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,14 @@ func (oc *OrphanController) updateDataCleanableCondition(orphan *longhorn.Orphan
623623
reason = oc.checkOrphanedReplicaDataCleanable(node, orphan)
624624
}
625625

626+
exist, err := datastore.IsLabelLonghornDeleteCustomResourceOnlyExisting(orphan)
627+
if err != nil {
628+
return errors.Wrapf(err, "failed to check if the label longhorn.io/delete-custom-resource-only exists")
629+
}
630+
if exist {
631+
reason = longhorn.OrphanConditionTypeDataCleanableReasonSkipped
632+
}
633+
626634
return nil
627635
}
628636

k8s/pkg/apis/longhorn/v1beta2/orphan.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const (
2020
OrphanConditionTypeDataCleanableReasonDiskInvalid = "DiskInvalid"
2121
OrphanConditionTypeDataCleanableReasonDiskEvicted = "DiskEvicted"
2222
OrphanConditionTypeDataCleanableReasonDiskChanged = "DiskChanged"
23+
OrphanConditionTypeDataCleanableReasonSkipped = "Skipped"
2324
)
2425

2526
const (

0 commit comments

Comments
 (0)