Skip to content

Commit e198edf

Browse files
Report the PowerFlex/ScaleIO disk copy failure during volume migration and fail the migration (#5542)
* Report the PowerFlex/ScaleIO disk copy failure during volume migration and fail the migration. * Code improvements * Addressed review comments
1 parent 52a9dbd commit e198edf

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/KVMStorageProcessor.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,14 +1988,20 @@ public Answer copyVolumeFromPrimaryToPrimary(CopyCommand cmd) {
19881988
}
19891989

19901990
destPool = storagePoolMgr.getStoragePool(destPrimaryStore.getPoolType(), destPrimaryStore.getUuid());
1991-
storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, destPool, cmd.getWaitInMillSeconds());
1992-
1993-
if (srcPrimaryStore.isManaged()) {
1994-
storagePoolMgr.disconnectPhysicalDisk(srcPrimaryStore.getPoolType(), srcPrimaryStore.getUuid(), srcVolumePath);
1995-
}
1991+
try {
1992+
storagePoolMgr.copyPhysicalDisk(volume, destVolumeName, destPool, cmd.getWaitInMillSeconds());
1993+
} catch (Exception e) { // Any exceptions while copying the disk, should send failed answer with the error message
1994+
String errMsg = String.format("Failed to copy volume: %s to dest storage: %s, due to %s", srcVol.getName(), destPrimaryStore.getName(), e.toString());
1995+
s_logger.debug(errMsg, e);
1996+
throw new CloudRuntimeException(errMsg);
1997+
} finally {
1998+
if (srcPrimaryStore.isManaged()) {
1999+
storagePoolMgr.disconnectPhysicalDisk(srcPrimaryStore.getPoolType(), srcPrimaryStore.getUuid(), srcVolumePath);
2000+
}
19962001

1997-
if (destPrimaryStore.isManaged()) {
1998-
storagePoolMgr.disconnectPhysicalDisk(destPrimaryStore.getPoolType(), destPrimaryStore.getUuid(), destVolumePath);
2002+
if (destPrimaryStore.isManaged()) {
2003+
storagePoolMgr.disconnectPhysicalDisk(destPrimaryStore.getPoolType(), destPrimaryStore.getUuid(), destVolumePath);
2004+
}
19992005
}
20002006

20012007
final VolumeObjectTO newVol = new VolumeObjectTO();

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/ScaleIOStorageAdaptor.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.File;
2121
import java.io.FileFilter;
22+
import java.util.Arrays;
2223
import java.util.HashMap;
2324
import java.util.List;
2425
import java.util.Map;
@@ -268,12 +269,20 @@ public KVMPhysicalDisk copyPhysicalDisk(KVMPhysicalDisk disk, String name, KVMSt
268269
srcFile = new QemuImgFile(disk.getPath(), disk.getFormat());
269270
destFile = new QemuImgFile(destDisk.getPath(), destDisk.getFormat());
270271

271-
LOGGER.debug("Starting copy from source image " + srcFile.getFileName() + " to PowerFlex volume: " + destDisk.getPath());
272+
LOGGER.debug("Starting copy from source disk image " + srcFile.getFileName() + " to PowerFlex volume: " + destDisk.getPath());
272273
qemu.convert(srcFile, destFile);
273-
LOGGER.debug("Succesfully converted source image " + srcFile.getFileName() + " to PowerFlex volume: " + destDisk.getPath());
274+
LOGGER.debug("Succesfully converted source disk image " + srcFile.getFileName() + " to PowerFlex volume: " + destDisk.getPath());
274275
} catch (QemuImgException | LibvirtException e) {
275-
LOGGER.error("Failed to convert from " + srcFile.getFileName() + " to " + destFile.getFileName() + " the error was: " + e.getMessage(), e);
276-
destDisk = null;
276+
try {
277+
Map<String, String> srcInfo = qemu.info(srcFile);
278+
LOGGER.debug("Source disk info: " + Arrays.asList(srcInfo));
279+
} catch (Exception ignored) {
280+
LOGGER.warn("Unable to get info from source disk: " + disk.getName());
281+
}
282+
283+
String errMsg = String.format("Unable to convert/copy from %s to %s, due to: %s", disk.getName(), name, ((Strings.isNullOrEmpty(e.getMessage())) ? "an unknown error" : e.getMessage()));
284+
LOGGER.error(errMsg);
285+
throw new CloudRuntimeException(errMsg, e);
277286
}
278287

279288
return destDisk;

0 commit comments

Comments
 (0)