CSTACKEX-212: fix for snapshot failure for attached cs volumes nfs an…#77
Open
sathvikaragi wants to merge 2 commits into
Open
CSTACKEX-212: fix for snapshot failure for attached cs volumes nfs an…#77sathvikaragi wants to merge 2 commits into
sathvikaragi wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes snapshot failures for ONTAP-backed volumes that are created-and-attached to running VMs in a single step by ensuring the volume’s image format is set consistently (KVM → QCOW2) during ONTAP volume creation.
Changes:
- Set
VolumeVO.formatduringcreateAsync()for both iSCSI and NFS3 ONTAP-managed volumes based on the pool hypervisor. - Add unit-test stubbing for
StoragePool.getHypervisor()to support the new format-resolution logic.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java | Set volume format during creation and add hypervisor→image-format resolution helper. |
| plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriverTest.java | Update tests to provide pool hypervisor needed by the new format-setting logic. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1013
to
+1018
| private Storage.ImageFormat getImageFormatByHypervisor(HypervisorType hypervisorType) { | ||
| if (hypervisorType == HypervisorType.KVM) { | ||
| return Storage.ImageFormat.QCOW2; | ||
| } | ||
| throw new CloudRuntimeException("Unsupported hypervisor [" + hypervisorType + "] for ONTAP image format resolution"); | ||
| } |
rajiv-jain-netapp
previously approved these changes
Jul 10, 2026
sandeeplocharla
previously approved these changes
Jul 10, 2026
sandeeplocharla
left a comment
Collaborator
There was a problem hiding this comment.
Awesome work!!!
suryag1201
reviewed
Jul 10, 2026
8856437
Comment on lines
+1011
to
+1016
| private Storage.ImageFormat getImageFormatByHypervisor(HypervisorType hypervisorType) { | ||
| if (hypervisorType.equals(HypervisorType.KVM)) { | ||
| return Storage.ImageFormat.QCOW2; | ||
| } | ||
| throw new CloudRuntimeException("Unsupported hypervisor [" + hypervisorType + "] for ONTAP image format resolution"); | ||
| } |
Comment on lines
168
to
172
| when(storagePoolDao.findById(1L)).thenReturn(storagePool); | ||
| when(storagePool.getId()).thenReturn(1L); | ||
| when(storagePool.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); | ||
| when(storagePool.getHypervisor()).thenReturn(Hypervisor.HypervisorType.KVM); | ||
|
|
Comment on lines
222
to
226
| when(storagePoolDao.findById(1L)).thenReturn(storagePool); | ||
| when(storagePool.getId()).thenReturn(1L); | ||
| when(storagePool.getPoolType()).thenReturn(Storage.StoragePoolType.NetworkFilesystem); | ||
| when(storagePool.getHypervisor()).thenReturn(Hypervisor.HypervisorType.KVM); | ||
| when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(storagePoolDetails); |
rajiv-jain-netapp
approved these changes
Jul 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix snapshot failure for CloudStack volumes attached to running VMs on ONTAP primary storage (both NFS3 and iSCSI protocols).
This PR...
When a volume was created and attached to a running VM in a single step, the volume format was not being set correctly. The format is now determined by the hypervisor type (KVM → QCOW2) via [getImageFormatByHypervisor(HypervisorType] mirroring the [getSupportedImageFormatForCluster] in VolumeOrchestrator file.
Unit tests updated and passing for success cases for both iSCSI and NFS3 volume creation
are covered in
OntapPrimaryDatastoreDriverTestTypes of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
For NFS created 2 instances one with both disks and one with root disk only and attached volumes and took snapshots
similar for iscsi:



reflected in DB:


FOR ISCSI :
FOR NFS :
How Has This Been Tested?
Tested on a dev setup against 4 scenarios:
Scenario A — Attach data disk to running VM, then snapshot
Scenario B — Attach volume to root-disk-only VM, then snapshot
How did you try to break this feature and the system with this change?