Skip to content

Commit 0241017

Browse files
Gupta, SuryaGupta, Surya
authored andcommitted
CSTACKEX-16 Fix Copy Issues in KVM for managed storage
1 parent b82d399 commit 0241017

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/driver/OntapPrimaryDatastoreDriver.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -629,13 +629,12 @@ private void deleteSnapshotClone(SnapshotInfo snapshotInfo, DataStore store) {
629629
Map<String, String> details = storagePoolDetailsDao.listDetailsKeyPairs(store.getId());
630630
StorageStrategy storageStrategy = Utility.getStrategyByStoragePoolDetails(details);
631631

632-
// Build the ONTAP LUN name using the snapshot name (consistent with grantAccessForSnapshot/revokeAccessForSnapshot)
633-
// Do NOT use snapshotInfo.getPath() — that holds the iSCSI path (/<IQN>/<LUN>), not the ONTAP LUN name.
634-
if (snapshotInfo.getName() == null || snapshotInfo.getName().isEmpty()) {
635-
s_logger.warn("deleteSnapshotClone: Snapshot name is null/empty for snapshot id: {}, nothing to delete", snapshotInfo.getId());
632+
// Get the cloned LUN name from snapshotInfo.getPath() (set during takeSnapshot)
633+
String snapshotLunName = snapshotInfo.getPath();
634+
if (snapshotLunName == null) {
635+
s_logger.warn("deleteSnapshotClone: Snapshot path is null for snapshot id: {}, nothing to delete", snapshotInfo.getId());
636636
return;
637637
}
638-
String snapshotLunName = Constants.VOL + storagePool.getName() + Constants.SLASH + snapshotInfo.getName();
639638

640639
// Get the cloned LUN UUID from snapshot_details
641640
SnapshotDetailsVO snapDetail = snapshotDetailsDao.findDetail(snapshotInfo.getSnapshotId(), Constants.ONTAP_SNAP_ID);
@@ -712,18 +711,8 @@ public void takeSnapshot(SnapshotInfo snapshot, AsyncCompletionCallback<CreateCm
712711
SnapshotObjectTO snapshotObjectTo = (SnapshotObjectTO)snapshot.getTO();
713712
CloudStackVolume snapshotCloudStackVolumeRequest = snapshotCloudStackVolumeRequestByProtocol(poolDetails, storagePool, cloudStackVolume, snapshot);
714713
CloudStackVolume clonedCloudStackVolume = storageStrategy.copyCloudStackVolume(snapshotCloudStackVolumeRequest);
715-
UnifiedSANStrategy sanStrategy = (UnifiedSANStrategy) Utility.getStrategyByStoragePoolDetails(poolDetails);
716-
String accessGroupName = Utility.getIgroupName(poolDetails.get(Constants.SVM_NAME), storagePool.getUuid());
717-
718-
// Map the snapshot's cloned LUN to the igroup
719-
String lunNumber = sanStrategy.ensureLunMapped(poolDetails.get(Constants.SVM_NAME), clonedCloudStackVolume.getLun().getName(), accessGroupName);
720-
// Store DiskTO.IQN in snapshot_details so StorageSystemDataMotionStrategy.getSnapshotDetails()
721-
// can build the iSCSI source details for the CopyCommand sent to the KVM agent
722-
723-
// Update volume path if changed (e.g., after migration or re-mapping)
724-
String iscsiPath = Constants.SLASH + storagePool.getPath() + Constants.SLASH + lunNumber;
725714
if (ProtocolType.ISCSI.name().equalsIgnoreCase(poolDetails.get(Constants.PROTOCOL))) {
726-
snapshotObjectTo.setPath(iscsiPath);
715+
snapshotObjectTo.setPath(clonedCloudStackVolume.getLun().getName());
727716
snapshotId = clonedCloudStackVolume.getLun().getUuid();
728717
snapshotSize = clonedCloudStackVolume.getLun().getSpace().getSize();
729718
}

0 commit comments

Comments
 (0)