mirror of https://github.com/apache/cloudstack.git
api: correct error on resize volume resource allocation failure (#7687)
This PR resource throws exception with the correct error code and logs the error message when a resource allocation failure is encountered during resize volume operation. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
f3ad9e6743
commit
de6ce503dc
|
|
@ -184,7 +184,7 @@ public class ResizeVolumeCmd extends BaseAsyncCmd implements UserCmd {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws ResourceAllocationException {
|
||||
public void execute() {
|
||||
Volume volume = null;
|
||||
try {
|
||||
if (size != null) {
|
||||
|
|
@ -194,6 +194,9 @@ public class ResizeVolumeCmd extends BaseAsyncCmd implements UserCmd {
|
|||
}
|
||||
|
||||
volume = _volumeService.resizeVolume(this);
|
||||
} catch (ResourceAllocationException ex) {
|
||||
s_logger.error(ex.getMessage());
|
||||
throw new ServerApiException(ApiErrorCode.RESOURCE_ALLOCATION_ERROR, ex.getMessage());
|
||||
} catch (InvalidParameterValueException ex) {
|
||||
s_logger.info(ex.getMessage());
|
||||
throw new ServerApiException(ApiErrorCode.UNSUPPORTED_ACTION_ERROR, ex.getMessage());
|
||||
|
|
|
|||
|
|
@ -129,9 +129,7 @@ public class ApiAsyncJobDispatcher extends AdapterBase implements AsyncJobDispat
|
|||
response.setErrorText(errorMsg);
|
||||
response.setResponseName((cmdObj == null) ? "unknowncommandresponse" : cmdObj.getCommandName());
|
||||
|
||||
// FIXME: setting resultCode to ApiErrorCode.INTERNAL_ERROR is not right, usually executors have their exception handling
|
||||
// and we need to preserve that as much as possible here
|
||||
_asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, ApiErrorCode.INTERNAL_ERROR.getHttpCode(), ApiSerializerHelper.toSerializedString(response));
|
||||
_asyncJobMgr.completeAsyncJob(job.getId(), JobInfo.Status.FAILED, errorCode, ApiSerializerHelper.toSerializedString(response));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue