Kukunin opened a new pull request, #13043:
URL: https://github.com/apache/cloudstack/pull/13043

   ### Description
   
   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` entirely
   - 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`.
   
   Fixes: #11451
   
   ### Types of changes
   
   - [ ] Breaking change (fix or feature that would cause existing 
functionality to change)
   - [ ] New feature (non-breaking change which adds functionality)
   - [x] Bug fix (non-breaking change which fixes an issue)
   - [ ] Enhancement (improves an existing feature and functionality)
   - [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
   - [ ] Build/CI
   - [ ] Test (unit or integration test code)
   
   ### Feature/Enhancement Scale or Bug Severity
   
   #### Feature/Enhancement Scale
   
   - [ ] Major
   - [ ] Minor
   
   #### Bug Severity
   
   - [ ] BLOCKER
   - [ ] Critical
   - [x] Major
   - [ ] Minor
   - [ ] Trivial
   
   ### How Has This Been Tested?
   
   **Unit tests:** 5 new tests added to `LinstorPrimaryDataStoreDriverImplTest`:
   - `testGetCapabilitiesIncludesCreateTemplateFromSnapshot` — verifies the 
capability is advertised
   - `testCanCopySnapshotToVolumeOnSamePrimary` — verifies `canCopy()` returns 
true for SNAPSHOT → VOLUME on same Linstor primary
   - `testCanCopySnapshotToVolumeRejectsNonLinstor` — verifies `canCopy()` 
returns false for non-Linstor storage
   - `testCanCopySnapshotToVolumeRejectsCrossPrimary` — verifies `canCopy()` 
returns false across different primary stores
   - `testCanCopySnapshotToVolumeRejectsImageDest` — verifies `canCopy()` 
returns false when destination is Image store
   
   **Integration test:** Tested on CloudStack 4.22 with Linstor LVM_THIN 
storage (DRBD-replicated across 3 nodes), creating a volume from a 1TB CNPG 
Postgres database snapshot via `createVolume` API:
   - Volume creates successfully with state=Ready and correct UUID path
   - Volume deletes cleanly (both CloudStack DB and Linstor resource)
   - Linstor resource is properly created via native snapshot restore 
(`resourceSnapshotRestore` API)
   
   #### How did you try to break this feature and the system with this change?
   
   - Verified that the existing `canCopy()` paths (SNAPSHOT→SNAPSHOT to Image, 
TEMPLATE→TEMPLATE, VOLUME→VOLUME/TEMPLATE) are not affected by the new 
condition being checked first
   - Verified cross-primary-store and non-Linstor scenarios are rejected
   - Verified volume path is stored as UUID (not device path) to ensure delete 
operations work correctly
   - The change is confined to the Linstor plugin — no modifications to shared 
CloudStack code


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to