Repository navigation
ONTAP: cache templates on primary storage and clone volumes from them - #14243
rajiv-jain-netapp wants to merge 3 commits into
Conversation
Enable the managed-storage template cache flow for the ONTAP primary storage plugin so that VM root volumes are cloned from a template copy kept on the pool's FlexVolume instead of being copied from secondary storage for every deployment. - Advertise CAN_CREATE_VOLUME_FROM_VOLUME from the datastore driver. - Create the template cache on primary: an iSCSI LUN (identity tracked on template_spool_ref) or a qcow2 file for NFS, populated by the KVM host. - Clone new volumes from the cached template: LUN clone for iSCSI and ONTAP file clone (FileCloneRequest) for NFS, growing the clone when the disk offering is larger than the template. - Clean up the cached LUN/file when the template is removed from the pool; a missing file is treated as already deleted. - Move protocol-specific create/clone/resize logic into UnifiedSANStrategy and UnifiedNASStrategy, and add a StorageStrategy helper to poll an optional async job. - Add unit tests for the driver and the NAS/SAN strategies.
c4080ea to
9ab7ec5
Compare
|
@blueorangutan package |
|
@DaanHoogland @nvazquez this PR needs to be tagged for 4.24, can you do the needful? |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #14243 +/- ##
============================================
+ Coverage 20.05% 20.53% +0.48%
- Complexity 20656 21535 +879
============================================
Files 6427 6488 +61
Lines 584905 589871 +4966
Branches 71658 72296 +638
============================================
+ Hits 117278 121159 +3881
- Misses 454802 455537 +735
- Partials 12825 13175 +350
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open findings
pollJobIfPresentignores the boolean return value ofjobPollForSuccess, so async job failures… · NewtemplatePoolRef.getTemplateSize()can be null (or 0) depending on how the spool ref row was… · New This hard cast toUnifiedNASStrategycan trigger aClassCastExceptionif… · NewupdateCloudStackVolumeMetadata(...)is called without verifying… · New
What changed in this PR
Enables ONTAP primary-storage template caching so VM root disks are created via array-side clones (LUN clone for iSCSI, file clone for NFS) instead of re-copying from secondary storage each deployment.
Changes:
- Adds template-cache create/clone/resize flows to the ONTAP primary datastore driver and SAN/NAS strategies.
- Introduces ONTAP NFS file-clone request model and new Feign API(s), plus SAN LUN clone/resize behavior.
- Expands unit tests to cover template caching, cloning, and resize error handling.
| File | Description |
|---|---|
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java | Implements template-cache create/delete and volume clone-from-template logic; adds pool capability. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedSANStrategy.java | Adds SAN template-cache LUN creation, LUN clone, and LUN resize implementation. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java | Adds NAS file clone, host-side qcow2 resize, and “delete file by path” helper. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java | Extends strategy API with template-cache create, clone, resize, and job polling helper. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java | Adds ONTAP file clone endpoint. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/SANFeignClient.java | Updates LUN PATCH endpoint and headers for resizing. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/FileCloneRequest.java | New request model for ONTAP file clone API. |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java | Removes protocol-specific volume request builder (now handled in driver). |
| plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java | Adds template LUN prefix constant and clone-of-template volume detail key. |
| plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/UnifiedSANStrategyTest.java | Adds tests for template cache, clone, resize, and incomplete LUN responses. |
| plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/UnifiedNASStrategyTest.java | Adds tests for file clone, host-side resize, and 404-on-delete behavior. |
| plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriverTest.java | Adds tests covering template cache lifecycle and clone/resize integration paths. |
| plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java | Updates test stub for new strategy interface methods. |
🧠 Review effort: Lite
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
DaanHoogland
left a comment
There was a problem hiding this comment.
clgtm; nothing strange to se on a quick review. The code is contained in the ontap plugin completely so I think we must trust the maintainers on this one.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
5 open issues
Long.valueOf(detail.getValue())may throwNumberFormatExceptionif the persisted value is… · New The Javadoc states “NAS returns an empty volume” / “return … an empty CloudStackVolume”, but… · NewLong.parseLong(cloudstackVolume.getDatastoreId())can throwNumberFormatException, which… · NewMap.of(...)throws aNullPointerExceptionifsvmNameorlunNameis null, which can prevent… · NewupdateCloudStackVolumeMetadata(...)is called without verifying…
3 resolved since last review
Review effort: Lite
|
@nvazquez @RosiKyu , please pass judgement ;) @rajiv-jain-netapp can you address the co-pilot remarks so far? |
|
Thanks @DaanHoogland - @rajiv-jain-netapp can confirm but in my understanding this PR needs #13897 and #14192 first. We can proceed with this one after these 2 are merged |
@nvazquez yes, Nicolas, I would recommend following the sequence on the PRs as I sent in mail, would help in staying away from integration issues |
Hi @DaanHoogland thanks for the approval. @nvazquez taken care of the co-pilot comments |


Enable the managed-storage template cache flow for the ONTAP primary storage plugin so that VM root volumes are cloned from a template copy kept on the pool's FlexVolume instead of being copied from secondary storage for every deployment.
Description
This PR...
Types of changes
Feature/Enhancement Scale or Bug Severity
Feature/Enhancement Scale
Bug Severity
Screenshots (if appropriate):
How Has This Been Tested?