From 0e4d91aa91c51b89466293754622b7a4289166f9 Mon Sep 17 00:00:00 2001 From: Devdeep Singh Date: Fri, 14 Nov 2014 11:11:49 +0530 Subject: [PATCH] CLOUDSTACK-6924. To attach a volume if a volume needs to be moved to another storage pool, the source and destination pools cannot be local and cluster/zone and vice versa. Cloudstack detects it and throws a exception. However, the end user only sees an unexpected exception and not the reason for failure. Fixed it by making sure the reason for the failure is correctly captured and shown to the end user. (cherry picked from commit cffae8eef0b1f9bf869a5ec99befbe9ae9d9290d) Signed-off-by: Rohit Yadav Conflicts: server/src/com/cloud/storage/VolumeApiServiceImpl.java --- .../orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java | 4 ++++ server/src/com/cloud/storage/VolumeApiServiceImpl.java | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java index c023511a224..bbbf7fd4026 100644 --- a/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java +++ b/engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java @@ -28,6 +28,7 @@ import org.apache.cloudstack.framework.jobs.AsyncJobDispatcher; import org.apache.cloudstack.framework.jobs.AsyncJobManager; import org.apache.cloudstack.jobs.JobInfo; +import com.cloud.exception.InvalidParameterValueException; import com.cloud.utils.Pair; import com.cloud.utils.component.AdapterBase; import com.cloud.vm.dao.VMInstanceDao; @@ -108,6 +109,9 @@ public class VmWorkJobDispatcher extends AdapterBase implements AsyncJobDispatch if (s_logger.isDebugEnabled()) s_logger.debug("Done with run of VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated()); } + } catch(InvalidParameterValueException e) { + s_logger.error("Unable to complete " + job + ", job origin:" + job.getRelated()); + _asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, _asyncJobMgr.marshallResultObject(e)); } catch(Throwable e) { s_logger.error("Unable to complete " + job + ", job origin:" + job.getRelated(), e); diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index fe46b1cb503..219a48299c7 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -2244,7 +2244,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic return false; } } - throw new CloudRuntimeException("Can't move volume between scope: " + storeForNewStoreScope.getScopeType() + " and " + storeForExistingStoreScope.getScopeType()); + throw new InvalidParameterValueException("Can't move volume between scope: " + storeForNewStoreScope.getScopeType() + " and " + storeForExistingStoreScope.getScopeType()); } return !storeForExistingStoreScope.isSameScope(storeForNewStoreScope);