From 7785d7f46966cbac0da9a8a78d860af376e80596 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 6 Nov 2025 15:53:20 +0800 Subject: [PATCH] feat: enable snapshot and clone for LHv2 (#379) (#587) Now that Longhorn supports volume clone with the V2 data engine, we can enable volume snapshot and clone. Related issue: https://github.com/harvester/harvester/issues/6710 (cherry picked from commit a1cf41bda92ceb399be21904ec267311f9568bdb) Signed-off-by: Tim Serong Co-authored-by: Tim Serong --- .../models/harvester/persistentvolumeclaim.js | 15 +++------------ .../models/kubevirt.io.virtualmachine.js | 16 +++++----------- 2 files changed, 8 insertions(+), 23 deletions(-) diff --git a/pkg/harvester/models/harvester/persistentvolumeclaim.js b/pkg/harvester/models/harvester/persistentvolumeclaim.js index ff7f8d81..44f751f4 100644 --- a/pkg/harvester/models/harvester/persistentvolumeclaim.js +++ b/pkg/harvester/models/harvester/persistentvolumeclaim.js @@ -35,15 +35,10 @@ export default class HciPv extends HarvesterResource { get availableActions() { let out = super._availableActions; - // Longhorn V2 provisioner do not support volume clone feature yet - if (this.isLonghornV2) { - out = out.filter((action) => action.action !== 'goToClone'); - } else { - const clone = out.find((action) => action.action === 'goToClone'); + const clone = out.find((action) => action.action === 'goToClone'); - if (clone) { - clone.action = 'goToCloneVolume'; - } + if (clone) { + clone.action = 'goToCloneVolume'; } const exportImageAction = { @@ -65,10 +60,6 @@ export default class HciPv extends HarvesterResource { takeSnapshotAction, ...out ]; - // TODO: remove this block if Longhorn V2 engine supports restore volume snapshot - if (this.isLonghornV2) { - out = out.filter((action) => action.action !== takeSnapshotAction.action); - } } else { // v1.4 / v1.3 if (!this.isLonghorn || !this.isLonghornV2) { out = [ diff --git a/pkg/harvester/models/kubevirt.io.virtualmachine.js b/pkg/harvester/models/kubevirt.io.virtualmachine.js index 3071c3a1..1a3a1622 100644 --- a/pkg/harvester/models/kubevirt.io.virtualmachine.js +++ b/pkg/harvester/models/kubevirt.io.virtualmachine.js @@ -87,17 +87,11 @@ const IgnoreMessages = ['pod has unbound immediate PersistentVolumeClaims']; export default class VirtVm extends HarvesterResource { get availableActions() { - let out = super._availableActions; + const out = super._availableActions; + const clone = out.find((action) => action.action === 'goToClone'); - // VM attached with Longhorn V2 volume doesn't support clone feature - if (this.longhornV2Volumes.length > 0) { - out = out.filter((action) => action.action !== 'goToClone'); - } else { - const clone = out.find((action) => action.action === 'goToClone'); - - if (clone) { - clone.action = 'goToCloneVM'; - } + if (clone) { + clone.action = 'goToCloneVM'; } return [ @@ -159,7 +153,7 @@ export default class VirtVm extends HarvesterResource { }, { action: 'takeVMSnapshot', - enabled: (!!this.actions?.snapshot || !!this.action?.backup) && !this.longhornV2Volumes.length, + enabled: (!!this.actions?.snapshot || !!this.action?.backup), icon: 'icon icon-snapshot', label: this.t('harvester.action.vmSnapshot') },