Skip to content

Commit 5f9143c

Browse files
CSTACKEX-198: keeping ONTAP clone object name unique with pattern as <"Snapshot_base_name_from_CS"+"snapshot_id"+"CS-Volume_id">
1 parent 236c966 commit 5f9143c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/vmsnapshot/OntapVMSnapshotStrategy.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ public VMSnapshot takeVMSnapshot(VMSnapshot vmSnapshot) {
389389
// Create one clone per CloudStack volume and persist detail for protocol-specific revert.
390390
for (Long volumeId : groupInfo.volumeIds) {
391391
String volumePath = resolveVolumePathOnOntap(volumeId, protocol, groupInfo.poolDetails);
392-
String cloneName = snapshotNameBase;
392+
String cloneName = buildPerVolumeCloneName(snapshotNameBase, vmSnapshot.getId(), volumeId);
393393
String cloneUuid = cloneName;
394394
if (ProtocolType.NFS3.name().equalsIgnoreCase(protocol)) {
395395
org.apache.cloudstack.storage.feign.model.FileCloneRequest cloneRequest = new org.apache.cloudstack.storage.feign.model.FileCloneRequest();
@@ -725,6 +725,14 @@ String buildSnapshotName(VMSnapshot vmSnapshot) {
725725
return OntapStorageUtils.getOntapCloneName(vmSnapshot.getName());
726726
}
727727

728+
/**
729+
* Builds a deterministic per-volume clone name for VM snapshot workflows.
730+
* Keeps VM snapshot name as base while preventing collisions across ROOT/DATA volumes.
731+
*/
732+
String buildPerVolumeCloneName(String snapshotNameBase, Long vmSnapshotId, Long volumeId) {
733+
return OntapStorageUtils.getOntapCloneName(snapshotNameBase + "_s" + vmSnapshotId + "_v" + volumeId);
734+
}
735+
728736
String resolveLunUuid(StorageStrategy strategy, String authHeader, String svmName, String lunName) {
729737
OntapResponse<org.apache.cloudstack.storage.feign.model.Lun> response = strategy.getSanFeignClient()
730738
.getLunResponse(authHeader, Map.of(OntapStorageConstants.SVM_DOT_NAME, svmName, OntapStorageConstants.NAME, lunName));

0 commit comments

Comments
 (0)