cloudstack/plugins/storage/volume
Sergiy Kukunin 089eb36e47
Linstor: fix create volume from snapshot on primary storage (#13043)
* Linstor: fix create volume from snapshot on primary storage

When creating a volume from a snapshot on Linstor primary storage
(with lin.backup.snapshots=false), the operation fails with:
"Only the following image types are currently supported: VHD, OVA,
QCOW2, RAW (for PowerFlex and FiberChannel)"

Root cause: the Linstor driver does not handle SNAPSHOT -> VOLUME in
its canCopy()/copyAsync() methods. This causes DataMotionServiceImpl
to fall through to StorageSystemDataMotionStrategy (selected because
Linstor advertises STORAGE_SYSTEM_SNAPSHOT=true). That strategy's
verifyFormatWithPoolType() rejects RAW format for Linstor pools,
since RAW is only allowed for PowerFlex and FiberChannel.

Additionally, VolumeOrchestrator.createVolumeFromSnapshot() attempts
to back up the snapshot to secondary storage when the storage plugin
does not advertise CAN_CREATE_TEMPLATE_FROM_SNAPSHOT. This backup
fails because the snapshot only exists on Linstor primary storage.

Fix:
- Add CAN_CREATE_TEMPLATE_FROM_SNAPSHOT capability so the
  orchestrator skips the backup-to-secondary path
- Add canCopySnapshotToVolumeCond() to match SNAPSHOT -> VOLUME
  when both are on the same Linstor primary store
- Wire it into canCopy() to intercept at DataMotionServiceImpl
  before strategy selection, bypassing StorageSystemDataMotionStrategy
- Implement copySnapshotToVolume() which delegates to the existing
  createResourceFromSnapshot() for native Linstor snapshot restore

This follows the same pattern used by the StorPool plugin, which
handles SNAPSHOT -> VOLUME directly in its driver rather than going
through StorageSystemDataMotionStrategy.

Tested on CloudStack 4.22 with Linstor LVM_THIN storage, creating
a volume from a 1TB CNPG Postgres database snapshot. Volume creates
successfully with correct path and deletes cleanly.

* Let CloudRuntimeException propagate from copySnapshotToVolume

Remove try/catch in copySnapshotToVolume so that CloudRuntimeException
from createResourceFromSnapshot propagates to the caller, ensuring
CloudStack properly notices and reports the failure.

* Fix CAN_CREATE_TEMPLATE_FROM_SNAPSHOT breaking template creation

Setting CAN_CREATE_TEMPLATE_FROM_SNAPSHOT unconditionally to true
caused createTemplate from snapshot to take the StorPool-specific
code path in TemplateManagerImpl, which sends a CopyCommand to a
system VM that Linstor cannot handle.

Fix: make CAN_CREATE_TEMPLATE_FROM_SNAPSHOT conditional on the same
flag as STORAGE_SYSTEM_SNAPSHOT (!BackupSnapshots). When snapshots
are backed up to secondary (the default), the old template creation
flow works. When snapshots stay on primary, the direct path is used.

Also fix checkstyle: remove unused DataObject import in test.

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-29 11:23:08 +05:30
..
adaptive Updating pom.xml version numbers for release 4.23.0.0-SNAPSHOT 2025-11-05 16:54:39 +05:30
cloudbyte Merge branch '4.22' 2025-12-22 14:13:50 +01:00
datera Merge release branch 4.22 to main 2026-01-26 13:32:56 +01:00
default Merge branch '4.22' 2026-04-14 14:50:44 +02:00
flasharray Updating pom.xml version numbers for release 4.23.0.0-SNAPSHOT 2025-11-05 16:54:39 +05:30
linstor Linstor: fix create volume from snapshot on primary storage (#13043) 2026-04-29 11:23:08 +05:30
nexenta removed code in comments (#11145) 2025-12-08 16:31:48 +01:00
ontap Create, Delete, Enable, Disable, Enter, Cancel maintenance of Primary StoragePool with ONTAP storage (#12563) 2026-04-13 08:38:15 -03:00
primera Merge branch '4.22' 2026-04-14 14:50:44 +02:00
sample Updating pom.xml version numbers for release 4.23.0.0-SNAPSHOT 2025-11-05 16:54:39 +05:30
scaleio Merge branch '4.22' 2026-04-02 10:30:18 +05:30
solidfire Merge release branch 4.22 to main 2026-01-26 13:32:56 +01:00
storpool Merge release branch 4.22 to main 2026-01-26 13:32:56 +01:00