Skip to content

Commit cffae8e

Browse files
committed
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.
1 parent e92f429 commit cffae8e

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎engine/orchestration/src/com/cloud/vm/VmWorkJobDispatcher.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.cloudstack.framework.jobs.AsyncJobManager;
2929
import org.apache.cloudstack.jobs.JobInfo;
3030

31+
import com.cloud.exception.InvalidParameterValueException;
3132
import com.cloud.utils.Pair;
3233
import com.cloud.utils.component.AdapterBase;
3334
import com.cloud.vm.dao.VMInstanceDao;
@@ -108,6 +109,9 @@ public void runJob(AsyncJob job) {
108109
if (s_logger.isDebugEnabled())
109110
s_logger.debug("Done with run of VM work job: " + cmd + " for VM " + work.getVmId() + ", job origin: " + job.getRelated());
110111
}
112+
} catch(InvalidParameterValueException e) {
113+
s_logger.error("Unable to complete " + job + ", job origin:" + job.getRelated());
114+
_asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, 0, _asyncJobMgr.marshallResultObject(e));
111115
} catch(Throwable e) {
112116
s_logger.error("Unable to complete " + job + ", job origin:" + job.getRelated(), e);
113117

‎server/src/com/cloud/storage/VolumeApiServiceImpl.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,8 @@ public Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId) {
13651365
if (jobResult != null) {
13661366
if (jobResult instanceof ConcurrentOperationException)
13671367
throw (ConcurrentOperationException)jobResult;
1368+
else if (jobResult instanceof InvalidParameterValueException)
1369+
throw (InvalidParameterValueException)jobResult;
13681370
else if (jobResult instanceof Throwable)
13691371
throw new RuntimeException("Unexpected exception", (Throwable)jobResult);
13701372
else if (jobResult instanceof Long) {
@@ -2141,7 +2143,7 @@ private boolean needMoveVolume(VolumeVO existingVolume, VolumeInfo newVolume) {
21412143
return false;
21422144
}
21432145
}
2144-
throw new CloudRuntimeException("Can't move volume between scope: " + storeForNewStoreScope.getScopeType() + " and " + storeForExistingStoreScope.getScopeType());
2146+
throw new InvalidParameterValueException("Can't move volume between scope: " + storeForNewStoreScope.getScopeType() + " and " + storeForExistingStoreScope.getScopeType());
21452147
}
21462148

21472149
return !storeForExistingStoreScope.isSameScope(storeForNewStoreScope);

0 commit comments

Comments
 (0)