Skip to content

Feature/cstackex 259 - #96

Open
rajiv-jain-netapp wants to merge 3 commits into
mainfrom
feature/CSTACKEX-259
Open

Feature/cstackex 259#96
rajiv-jain-netapp wants to merge 3 commits into
mainfrom
feature/CSTACKEX-259

Conversation

@rajiv-jain-netapp

@rajiv-jain-netapp rajiv-jain-netapp commented Aug 26, 2026

Copy link
Copy Markdown

This PR...
VM create workflow: by default orchestrtor does full copy of the image from secondary to primary pool.
With this change, we are enabling plugin to cache the template local to the storage pool. That would make subsequent VM instance create faster.

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):

How Has This Been Tested?

  1. On create of first VM with any given image in the scope of storage pool, I could see additional LUN/file created on the flexvolume on the storage.
  2. On creating subsequent VM with the same template, orchestrator is using the localy available cache instead performing full copy of the template from secondary. I confirm this from the logs by running the workflows.
  3. If user deletes all the VMs created for a given template then orchestrator would also clean up the cached template. It has been tested by deleting all the created VMs.

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

This PR enhances the ONTAP primary storage plugin to support template caching on the primary pool and subsequent fast VM disk provisioning via array-side cloning (instead of full template copies from secondary storage), including post-clone resizing when the service offering requires a larger disk.

Changes:

  • Introduces cloneCloudStackVolume and resizeCloudStackVolume in the ONTAP StorageStrategy abstraction and implements them for SAN (LUN clone + LUN PATCH resize) and NAS (file clone + host-side qcow2 resize).
  • Extends OntapPrimaryDatastoreDriver to (a) create and manage cached template objects on primary storage, (b) clone volumes from cached templates, and (c) handle template grant/revoke/delete workflows.
  • Updates ONTAP Feign clients/models and adds/extends tests to cover the new clone/resize and template-cache behaviors.

Reviewed changes

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

Show a summary per file
File Description
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java Implements template caching lifecycle and volume cloning-from-template flow; adds sizing and capabilities logic.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java Replaces copy no-op with clone + resize abstractions for protocol-specific implementations.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedSANStrategy.java Adds LUN clone creation and LUN resize (PATCH) support.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java Adds file-clone support and qcow2 growth via KVM ResizeVolumeCommand; adds delete-by-path helper.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java Adds constants for template cache LUN naming and the cloneOfTemplate volume detail key.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java Removes now-redundant request builder helper (logic moved into the driver).
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/SANFeignClient.java Fixes/updates LUN PATCH endpoint and headers for resize support.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/NASFeignClient.java Adds ONTAP file-clone API call definition.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Lun.java Adds JSON non-null inclusion for clone/source nested objects.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/FileCloneRequest.java Adds request model for ONTAP file clone API.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriverTest.java Adds coverage for template caching, clone-from-template, sizing, and template access lifecycle.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/UnifiedSANStrategyTest.java Adds tests for LUN clone and resize validation.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/UnifiedNASStrategyTest.java Adds tests for file clone, resize command dispatch, and delete-by-path behavior.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java Updates test stub to match new abstract strategy methods.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +402 to +405
String flexVolUuid = details.get(OntapStorageConstants.VOLUME_UUID);
((UnifiedNASStrategy) storageStrategy).deleteFileByPath(flexVolUuid, filePath);
logger.info("deleteTemplateOnPrimary: Deleted template cache file [{}] for template [{}]",
filePath, templateInfo.getId());
Comment on lines 938 to +946
public long getBytesRequiredForTemplate(TemplateInfo templateInfo, StoragePool storagePool) {
return 0;
if (templateInfo == null || storagePool == null) {
return 0;
}
// Already cached on this pool, so deploying from it costs no additional space.
if (vmTemplatePoolDao.findByPoolTemplate(storagePool.getId(), templateInfo.getId(), null) != null) {
return 0;
}
return getDataObjectSizeIncludingHypervisorSnapshotReserve(templateInfo, storagePool);
@github-actions

Copy link
Copy Markdown

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants