Skip to content

create temp CG for consistent VM snapshot for the VM which is span across multiple flexvolumes#74

Merged
rajiv-jain-netapp merged 15 commits into
mainfrom
feature/CSTACKEX-200
Jul 9, 2026
Merged

create temp CG for consistent VM snapshot for the VM which is span across multiple flexvolumes#74
rajiv-jain-netapp merged 15 commits into
mainfrom
feature/CSTACKEX-200

Conversation

@rajiv-jain-netapp

@rajiv-jain-netapp rajiv-jain-netapp commented Jul 2, 2026

Copy link
Copy Markdown

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 results and all the executed test cases added under previous PR #67

@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.

Partially reviewed. Still need to go through a good portion of OntapVMSnapshotStrategy.java and SnapshotManagerImpl.java

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 NetApp ONTAP managed-storage snapshot handling by ensuring VM snapshots remain consistent when a VM’s volumes span multiple FlexVols, and by preventing managed PRIMARY (array-native) volume snapshots from being incorrectly archived/bookkept as secondary snapshots.

Changes:

  • Add a temporary ONTAP Consistency Group (CG) two-phase snapshot flow for VM snapshots spanning multiple FlexVols; keep a direct FlexVol snapshot fast-path for single-FlexVol VMs.
  • Ensure managed PRIMARY volume snapshots (e.g., ONTAP volume snapshots) remain on primary/array storage and do not use secondary-archive bookkeeping paths.
  • Extend ONTAP integration utilities/strategy to better separate “provisioning-time” aggregate validation from “operations-only” connectivity, and add CG REST client APIs + related unit tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 4 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; refactors decision into archiveSnapshotToSecondary.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/vmsnapshot/OntapVMSnapshotStrategy.java Implements temporary CG orchestration for multi-FlexVol VM snapshots, plus single-FlexVol direct snapshot path and improved naming.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java Adds operations-only connect mode, job polling helpers, and centralized FlexVol snapshot delete orchestration.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java Adds snapshot naming helpers and an overload to connect with/without aggregate validation.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageConstants.java Adds SVM UUID support and CG/SFSR/delete polling constants.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java Persists resolved SVM UUID into pool details when available.
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/SnapshotFeignClient.java Adds ONTAP CG REST API endpoints (create/list CG, start/commit snapshot, delete CG).
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java Delegates volume-snapshot delete/revert to strategy helpers; updates naming and makes delete more robust/idempotent.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/vmsnapshot/OntapVMSnapshotStrategyTest.java Adds/updates unit tests for CG flow, naming, scope resolution, and avoids static utility connection issues.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java Adds tests for operations-only connect, job polling helpers, and FlexVol snapshot delete orchestration.
plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriverTest.java Updates capabilities expectations to include revert support.

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

return null;
}

private String getStringField(Map<String, Object> record, String key) {

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.

This can be in utils, instead.

if (eligibleAggregates.isEmpty()) {
logger.error("No suitable aggregates found on SVM " + svmName + " for volume operations.");
throw new CloudRuntimeException("No suitable aggregates found on SVM " + svmName + " for volume operations.");
this.resolvedSvmUuid = svm.getUuid();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since we are fetching svm uuid now , lets explicitly add uuid in queryParams

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I did not get this comment

Copilot AI review requested due to automatic review settings July 8, 2026 07:04

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 11 out of 11 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings July 8, 2026 13:24

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 11 out of 11 changed files in this pull request and generated 2 comments.

Comment on lines 720 to +724
VolumeDetailVO lunDetail = volumeDetailsDao.findDetail(volumeVO.getId(), OntapStorageConstants.LUN_DOT_UUID);
String lunUUID = lunDetail != null ? lunDetail.getValue() : null;
if (lunUUID == null) {
if (lunDetail.getValue() == null) {
throw new CloudRuntimeException("LUN UUID not found for iSCSI volume " + volumeVO.getId());
}
lunUuid = lunDetail.getValue();
sandeeplocharla
sandeeplocharla previously approved these changes Jul 9, 2026

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 11 out of 11 changed files in this pull request and generated 3 comments.

Comment on lines +977 to +981
/**
* Single GET attempt: try to match by name,
* then fall back to listing all CG snapshots in this group (And it would be one
* always since workflow is keep deleting the CG).
*/
String snapshotName = getSnapshotDetail(snapshotId, OntapStorageConstants.ONTAP_SNAP_NAME);
String poolIdStr = getSnapshotDetail(snapshotId, OntapStorageConstants.PRIMARY_POOL_ID);

if (flexVolUuid == null || ontapSnapshotUuid == null) {
Comment on lines +199 to +200
logger.info("Selected aggregate: " + aggr.getName() + " for volume operations.");
this.aggregates = List.of(aggr);
suryag1201
suryag1201 previously approved these changes Jul 9, 2026

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 15 out of 15 changed files in this pull request and generated 3 comments.

Comment on lines +195 to +211
public static String buildOntapSnapshotName(String cloudStackSnapshotName, String uniquenessSuffix) {
String normalizedBase = (cloudStackSnapshotName == null || cloudStackSnapshotName.trim().isEmpty())
? "snapshot"
: getOntapSnapshotName(cloudStackSnapshotName);
String suffix = (uniquenessSuffix == null || uniquenessSuffix.isEmpty())
? ""
: "_" + uniquenessSuffix.replaceAll("[^a-zA-Z0-9_]", "_");
int maxLength = OntapStorageConstants.MAX_SNAPSHOT_NAME_LENGTH;
int maxBaseLength = maxLength - suffix.length();
if (maxBaseLength <= 0) {
return normalizedBase.substring(0, maxLength);
}
if (normalizedBase.length() > maxBaseLength) {
normalizedBase = normalizedBase.substring(0, maxBaseLength);
}
return normalizedBase + suffix;
}
Comment on lines +977 to +981
/**
* Single GET attempt: try to match by name,
* then fall back to listing all CG snapshots in this group (And it would be one
* always since workflow is keep deleting the CG).
*/
Comment on lines +194 to +201
} else if (aggrResp.getSpace() == null || aggrResp.getAvailableBlockStorageSpace() == null ||
aggrResp.getAvailableBlockStorageSpace() <= storage.getSize().doubleValue()) {
logger.warn("Aggregate " + aggr.getName() + " does not have sufficient available space. Skipping this aggregate.");
continue;
}
logger.info("Selected aggregate: " + aggr.getName() + " for volume operations.");
this.aggregates = List.of(aggr);
break;
@rajiv-jain-netapp rajiv-jain-netapp merged commit ab25766 into main Jul 9, 2026
20 checks passed
@rajiv-jain-netapp rajiv-jain-netapp deleted the feature/CSTACKEX-200 branch July 9, 2026 15:12
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