Skip to content

Commit bbe29ae

Browse files
CSTACKEX-198: patch API return has to be void
1 parent edf5ade commit bbe29ae

6 files changed

Lines changed: 20 additions & 33 deletions

File tree

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -914,20 +914,13 @@ public void revertSnapshot(SnapshotInfo snapshotOnImageStore, SnapshotInfo snaps
914914
}
915915

916916
// Delegate to strategy class for protocol-specific restore
917-
JobResponse jobResponse = storageStrategy.revertSnapshotForCloudStackVolume(
917+
storageStrategy.revertSnapshotForCloudStackVolume(
918918
ontapCloneName, flexVolUuid, ontapCloneId, volumePath, lunUuid, flexVolName);
919919

920-
if (jobResponse == null || jobResponse.getJob() == null) {
921-
throw new CloudRuntimeException("Failed to initiate restore from snapshot [" +
922-
ontapCloneName + "]");
923-
}
924920

925-
// Poll for job completion (use longer timeout for large LUNs/files)
926-
Boolean jobSucceeded = storageStrategy.jobPollForSuccess(jobResponse.getJob().getUuid(), 60, 2000);
927-
if (!jobSucceeded) {
928-
throw new CloudRuntimeException("Restore job failed for snapshot [" +
929-
ontapCloneName + "]");
930-
}
921+
logger.info("revertSnapshot: iSCSI restore for [{}] completed without async job response; treating as synchronous success", volumePath);
922+
923+
callback.complete(result);
931924

932925
logger.info("revertSnapshot: Successfully restored {} [{}] from clone [{}]",
933926
ProtocolType.ISCSI.name().equalsIgnoreCase(protocol) ? "LUN" : "file",

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ public String getNetworkInterface() {
540540
* @param volumePath The path of the file/LUN within the FlexVolume
541541
* @param lunUuid The LUN UUID (only for iSCSI, null for NFS)
542542
* @param flexVolName The FlexVolume name (only for iSCSI, for constructing destination path)
543-
* @return JobResponse for the async restore operation
543+
* @return void
544544
*/
545-
public abstract JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid,
545+
public abstract void revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid,
546546
String snapshotUuid, String volumePath,
547547
String lunUuid, String flexVolName);
548548

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedNASStrategy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -447,10 +447,10 @@ private FileInfo getFile(String volumeUuid, String filePath) {
447447
* @param volumePath The file path within the FlexVolume
448448
* @param lunUuid Not used for NFS (null)
449449
* @param flexVolName The FlexVolume name (required for CLI API)
450-
* @return JobResponse for the async restore operation
450+
* @return void
451451
*/
452452
@Override
453-
public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid,
453+
public void revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid,
454454
String snapshotUuid, String volumePath,
455455
String lunUuid, String flexVolName) {
456456
logger.info("revertSnapshotForCloudStackVolume [NFS]: Reverting file [{}] using clone [{}] on FlexVol [{}]",
@@ -477,6 +477,6 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
477477
logger.debug("revertSnapshotForCloudStackVolume [NFS]: patch file source={} destination={} overwrite=true fill=false",
478478
snapshotName, volumePath);
479479
getNasFeignClient().updateFile(authHeader, flexVolUuid, volumePath, true, filePatchRequest);
480-
return null;
480+
481481
}
482482
}

plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/UnifiedSANStrategy.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.apache.cloudstack.storage.feign.model.OntapStorage;
3030
import org.apache.cloudstack.storage.feign.model.Lun;
3131
import org.apache.cloudstack.storage.feign.model.LunMap;
32-
import org.apache.cloudstack.storage.feign.model.response.JobResponse;
3332
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
3433
import org.apache.cloudstack.storage.service.model.AccessGroup;
3534
import org.apache.cloudstack.storage.service.model.CloudStackVolume;
@@ -556,10 +555,10 @@ public String ensureLunMapped(String svmName, String lunName, String accessGroup
556555
* @param volumePath The LUN name (used to construct the path)
557556
* @param lunUuid The LUN UUID (not used in CLI API, kept for interface consistency)
558557
* @param flexVolName The FlexVolume name (required for CLI API)
559-
* @return JobResponse for the async restore operation
558+
* @return void
560559
*/
561560
@Override
562-
public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid,
561+
public void revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid,
563562
String snapshotUuid, String volumePath,
564563
String lunUuid, String flexVolName) {
565564
logger.trace("revertSnapshotForCloudStackVolume [iSCSI]: Reverting LUN [{}] from clone [{}] on FlexVol [{}]",
@@ -608,7 +607,6 @@ public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String
608607
logger.debug("revertSnapshotForCloudStackVolume [iSCSI]: patch lun destinationUuid={} sourcePath={} sourceUuid={} destinationLun={}",
609608
destinationLunUuid, sourceLunPath, lunUuid, destinationLunPath);
610609
sanFeignClient.updateLun(authHeader, destinationLunUuid, revertCloneRequest);
611-
return null;
612610
}
613611

614612
private String resolveLunUuidByName(String authHeader, String svmName, String lunName) {

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ public boolean deleteVMSnapshot(VMSnapshot vmSnapshot) {
588588
DeleteVMSnapshotCommand deleteSnapshotCommand = new DeleteVMSnapshotCommand(vmInstanceName, vmSnapshotTO,
589589
volumeTOs, guestOS.getDisplayName());
590590

591-
// Check for FlexVolume snapshots (new approach)
591+
// Check for FlexVolume snapshots
592592
List<VMSnapshotDetailsVO> flexVolDetails = vmSnapshotDetailsDao.findDetails(vmSnapshot.getId(), OntapStorageConstants.ONTAP_FLEXVOL_SNAPSHOT);
593593
if (CollectionUtils.isNotEmpty(flexVolDetails)) {
594594
deleteFlexVolSnapshots(flexVolDetails);
@@ -888,16 +888,13 @@ void revertCloneBackedSnapshots(List<VMSnapshotDetailsVO> cloneDetails) {
888888
logger.info("revertCloneBackedSnapshots: Reverting volume [{}] using clone source [{}] on FlexVol [{}] (protocol={})",
889889
detail.volumePath, detail.snapshotName, flexVolName, detail.protocol);
890890
String lunUuid = ProtocolType.ISCSI.name().equalsIgnoreCase(detail.protocol) ? detail.snapshotUuid : null;
891-
JobResponse jobResponse = storageStrategy.revertSnapshotForCloudStackVolume(
892-
detail.snapshotName, detail.flexVolUuid, detail.snapshotUuid, detail.volumePath, lunUuid, flexVolName);
893-
894-
if (jobResponse != null && jobResponse.getJob() != null) {
895-
Boolean success = storageStrategy.jobPollForSuccess(jobResponse.getJob().getUuid(), 60, 2000);
896-
if (!success) {
897-
throw new CloudRuntimeException("Clone-backed revert failed for volume path [" +
898-
detail.volumePath + "] from clone [" + detail.snapshotName +
899-
"] on FlexVol [" + flexVolName + "]");
900-
}
891+
try {
892+
storageStrategy.revertSnapshotForCloudStackVolume(
893+
detail.snapshotName, detail.flexVolUuid, detail.snapshotUuid, detail.volumePath, lunUuid, flexVolName);
894+
} catch (Exception e) {
895+
logger.error("revertCloneBackedSnapshots: Revert of FlexVol snapshot failed: {}", e.getMessage(), e);
896+
throw new CloudRuntimeException("Failed to revert volume [" + detail.volumePath + "] from clone [" +
897+
detail.snapshotName + "] on FlexVol [" + flexVolName + "]: " + e.getMessage(), e);
901898
}
902899

903900
logger.info("revertCloneBackedSnapshots: Successfully reverted volume [{}] from clone [{}] on FlexVol [{}]",

plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,7 @@ public CloudStackVolume getCloudStackVolume(Map<String, String> cloudStackVolume
144144
}
145145

146146
@Override
147-
public JobResponse revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid, String snapshotUuid, String volumePath, String lunUuid, String flexVolName) {
148-
return null;
147+
public void revertSnapshotForCloudStackVolume(String snapshotName, String flexVolUuid, String snapshotUuid, String volumePath, String lunUuid, String flexVolName) {
149148
}
150149

151150
@Override

0 commit comments

Comments
 (0)