Skip to content

CSTACKEX:200 - added temp CG logic for VM snapshots if VM span across…#67

Open
rajiv-jain-netapp wants to merge 1 commit into
mainfrom
feature/CSTACKEX-200
Open

CSTACKEX:200 - added temp CG logic for VM snapshots if VM span across…#67
rajiv-jain-netapp wants to merge 1 commit into
mainfrom
feature/CSTACKEX-200

Conversation

@rajiv-jain-netapp

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

Copy link
Copy Markdown

… multiple volumes at storage

Description

This PR...

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?

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

@rajiv-jain-netapp

Copy link
Copy Markdown
Author

Testing:

  1. create snapshot at VM and cloudstack volume level
  2. Able to perform snapshot revert for both vm level and cloudstack volume level
  3. created VM with respective volumes at 2 flexvolumes with same protocol.
  4. tested with snapshot create and snapshot revert.
  5. tested for snapshot delete for all above 4 cases

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 extends CloudStack’s snapshot handling for ONTAP-managed storage by adding temporary consistency-group (CG) orchestration for VM snapshots that span multiple FlexVols, while also tightening snapshot archival behavior so managed-primary snapshots remain on array/primary storage.

Changes:

  • Add temporary ONTAP consistency-group (two-phase start+commit) flow for VM snapshots spanning multiple FlexVols; use direct FlexVol snapshots for single-FlexVol cases.
  • Adjust snapshot archival-to-secondary logic to avoid secondary bookkeeping/copy for managed primary snapshots (e.g., ONTAP volume snapshots kept on PRIMARY).
  • Refactor ONTAP strategy utilities: introduce “operations-only” connect mode, add job polling helpers, and centralize delete/revert logic in StorageStrategy.

Reviewed changes

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

Show a summary per file
File Description
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java Avoids archiving managed-primary snapshots to secondary; clarifies behavior and logging.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/vmsnapshot/OntapVMSnapshotStrategy.java Implements temporary CG orchestration for multi-FlexVol VM snapshots; refactors snapshot naming and strategy resolution.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java Changes strategy connection defaults and adds overload to control aggregate validation.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java Adds CG/SVM UUID constants and polling configuration knobs.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java Adds operations-only connect path, job polling helpers, and shared snapshot delete orchestration.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java Persists resolved SVM UUID into pool details during initialization.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/SnapshotFeignClient.java Adds Feign bindings for consistency-group and CG snapshot APIs.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java Delegates volume-snapshot delete and revert orchestration into StorageStrategy; updates capability flags and snapshot naming.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/vmsnapshot/OntapVMSnapshotStrategyTest.java Adds unit tests covering single-FlexVol vs CG flows, scope validation, and snapshot naming updates.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java Extends tests for operations-only connect and new polling/delete helpers.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriverTest.java Updates capability expectations (revert supported).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +122 to +128
/**
* Returns a connected {@link StorageStrategy} for operations on an existing pool (snapshots,
* delete, revert, grant/revoke). Does not require aggregate free space for the full pool size.
*/
public static StorageStrategy getStrategyByStoragePoolDetails(Map<String, String> details) {
return getStrategyByStoragePoolDetails(details, false);
}
Comment on lines +976 to +979
/**
* Single GET attempt: match by name, then fall back to listing all CG snapshots in this group (And it would one
* always since workflow is keep deleting the CG).
*/
@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.

if (lunUUID == null) {
throw new CloudRuntimeException("LUN UUID not found for iSCSI volume " + volumeVO.getId());
}
lunUuid = lunUUID;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

no need of this extra lunUuid variable assignment with temp lunUUID var, can be done directly also

name = StringUtils.left(volumeName, volumeName.length() - trimRequired) + "-" + snapshotUuid;
}
return name;
private String buildSnapshotName(String cloudStackSnapshotName, long snapshotId) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

as discussed, we have to check for two cloudstack using same ontap.

}
return name;
private String buildSnapshotName(String cloudStackSnapshotName, long snapshotId) {
return OntapStorageUtils.buildOntapSnapshotName(cloudStackSnapshotName, "cs" + snapshotId);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

we can move this cs to constant
Also, for better readability use - (hyphen)
Please add example for snapshot name

@RequestLine("POST /api/application/consistency-groups")
@Headers({"Authorization: {authHeader}", "Content-Type: application/json"})
JobResponse createConsistencyGroup(@Param("authHeader") String authHeader,
Map<String, Object> request);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

to create CG, request should be model type why map?

*/
@RequestLine("GET /api/application/consistency-groups")
@Headers({"Authorization: {authHeader}"})
OntapResponse<Map<String, Object>> getConsistencyGroups(@Param("authHeader") String authHeader,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

the return type should be OntapResponse

*/
@RequestLine("POST /api/application/consistency-groups/{cgUuid}/snapshots")
@Headers({"Authorization: {authHeader}", "Content-Type: application/json"})
JobResponse createConsistencyGroupSnapshot(@Param("authHeader") String authHeader,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same here for request

*/
@RequestLine("GET /api/application/consistency-groups/{cgUuid}/snapshots")
@Headers({"Authorization: {authHeader}"})
OntapResponse<Map<String, Object>> getConsistencyGroupSnapshots(@Param("authHeader") String authHeader,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same here for return type

* Presents aggregate object for the unified storage, not eligible for disaggregated
*/
private List<Aggregate> aggregates;
private String resolvedSvmUuid;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

svmUUID should be fine instead resolvedSvmUuid

groupInfo.volumeIds);
// CG orchestration is only required when VM disks span multiple FlexVols.
// A single FlexVol already provides atomic capture for all volumes on that FlexVol.
if (flexVolGroups.size() > 1) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can we also test, VM span across mutiple storage pool where svms are also diff

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.

4 participants