Skip to content

CSTACKEX-212: fix for snapshot failure for attached cs volumes nfs an…#77

Open
sathvikaragi wants to merge 2 commits into
mainfrom
bugfix/CSTACKEX-212
Open

CSTACKEX-212: fix for snapshot failure for attached cs volumes nfs an…#77
sathvikaragi wants to merge 2 commits into
mainfrom
bugfix/CSTACKEX-212

Conversation

@sathvikaragi

@sathvikaragi sathvikaragi commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

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 OntapPrimaryDatastoreDriverTest

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • 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
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

For NFS created 2 instances one with both disks and one with root disk only and attached volumes and took snapshots

Screenshot 2026-07-09 at 8 41 56 PM Screenshot 2026-07-09 at 8 40 57 PM Screenshot 2026-07-09 at 8 41 51 PM Screenshot 2026-07-09 at 8 56 37 PM

similar for iscsi:
Screenshot 2026-07-09 at 8 58 23 PM
Screenshot 2026-07-09 at 9 00 29 PM
Screenshot 2026-07-09 at 9 02 01 PM

reflected in DB:
FOR ISCSI :
Screenshot 2026-07-09 at 9 03 55 PM
FOR NFS :
Screenshot 2026-07-09 at 9 04 13 PM

How Has This Been Tested?

Tested on a dev setup against 4 scenarios:

Scenario A — Attach data disk to running VM, then snapshot

  • Create ONTAP primary storage pool (NFS3 or iSCSI)
  • Deploy VM with data disk using pool-tagged disk offering → VM reaches Running state
  • Create volume attached to the running VM in one step
  • Take snapshot of attached volume — ✅ succeeds (was failing before fix)

Scenario B — Attach volume to root-disk-only VM, then snapshot

  • Create ONTAP primary storage pool (NFS3 or iSCSI)
  • Deploy VM without data disk → VM reaches Running state
  • Create and attach volume to the running VM
  • Take snapshot of attached volume — ✅ succeeds (was failing before fix)

How did you try to break this feature and the system with this change?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.format during createAsync() 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");
}

@sandeeplocharla sandeeplocharla left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work!!!

Copilot AI review requested due to automatic review settings July 10, 2026 10:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

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);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants