mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6969. Data Volume Shrink operation failing with "Unexpected Exception".
For ResizeVolume API command - 1. If hypervisor resource throws an exception, handle the NPE thrown by the job framework. 2. Improve user error message in case of RuntimeException by throwing the exception instead of 'Unexpected Exception'.
This commit is contained in:
parent
fca41bf527
commit
f803100813
|
|
@ -1899,7 +1899,7 @@ public class LibvirtComputingResource extends ServerResourceBase implements Serv
|
|||
s_logger.debug("after resize, size reports as " + finalSize + ", requested " + newSize);
|
||||
return new ResizeVolumeAnswer(cmd, true, "success", finalSize);
|
||||
} catch (CloudRuntimeException e) {
|
||||
String error = "failed to resize volume: " + e;
|
||||
String error = "Failed to resize volume: " + e.getMessage();
|
||||
s_logger.debug(error);
|
||||
return new ResizeVolumeAnswer(cmd, false, error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -564,7 +564,8 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
VirtualDisk disk = vdisk.first();
|
||||
long oldSize = disk.getCapacityInKB();
|
||||
if (newSize < oldSize) {
|
||||
throw new Exception("VMware doesn't support shrinking volume from larger size: " + oldSize + " MB to a smaller size: " + newSize + " MB");
|
||||
throw new Exception("VMware doesn't support shrinking volume from larger size: " + oldSize/(1024*1024) + " GB to a smaller size: "
|
||||
+ newSize/(1024*1024) + " GB");
|
||||
} else if (newSize == oldSize) {
|
||||
return new ResizeVolumeAnswer(cmd, true, "success", newSize * 1024);
|
||||
}
|
||||
|
|
@ -582,7 +583,7 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||
return new ResizeVolumeAnswer(cmd, true, "success", newSize * 1024);
|
||||
} catch (Exception e) {
|
||||
s_logger.error("Unable to resize volume", e);
|
||||
String error = "failed to resize volume:" + e;
|
||||
String error = "Failed to resize volume: " + e.getMessage();
|
||||
return new ResizeVolumeAnswer(cmd, false, error);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -925,6 +925,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
if (jobResult instanceof ConcurrentOperationException) {
|
||||
throw (ConcurrentOperationException)jobResult;
|
||||
}
|
||||
else if (jobResult instanceof RuntimeException) {
|
||||
throw (RuntimeException)jobResult;
|
||||
}
|
||||
else if (jobResult instanceof Throwable) {
|
||||
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
|
||||
}
|
||||
|
|
@ -1000,7 +1003,11 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
VolumeApiResult result = future.get();
|
||||
if (result.isFailed()) {
|
||||
s_logger.warn("Failed to resize the volume " + volume);
|
||||
return null;
|
||||
String details = "";
|
||||
if (result.getResult() != null && !result.getResult().isEmpty()) {
|
||||
details = result.getResult();
|
||||
}
|
||||
throw new CloudRuntimeException(details);
|
||||
}
|
||||
|
||||
volume = _volsDao.findById(volume.getId());
|
||||
|
|
@ -1029,16 +1036,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
} else {
|
||||
_resourceLimitMgr.decrementResourceCount(volume.getAccountId(), ResourceType.primary_storage, volume.isDisplayVolume(), new Long(currentSize - newSize));
|
||||
}
|
||||
return volume;
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.warn("failed get resize volume result", e);
|
||||
} catch (ExecutionException e) {
|
||||
s_logger.warn("failed get resize volume result", e);
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("failed get resize volume result", e);
|
||||
}
|
||||
|
||||
return null;
|
||||
return volume;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue