You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ro...@apache.org on 2023/07/03 07:27:21 UTC
[cloudstack] branch 4.18 updated: api: correct error on resize volume resource allocation failure (#7687)
This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.18 by this push:
new de6ce503dce api: correct error on resize volume resource allocation failure (#7687)
de6ce503dce is described below
commit de6ce503dcef9c11fa88770445b20361956871d4
Author: Abhishek Kumar <ab...@gmail.com>
AuthorDate: Mon Jul 3 12:57:14 2023 +0530
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 <ab...@gmail.com>
---
.../apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java | 5 ++++-
server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java | 4 +---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
index 6ad512ad29a..0daf141ba4a 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/user/volume/ResizeVolumeCmd.java
@@ -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());
diff --git a/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java b/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java
index 196f640252a..b596254994c 100644
--- a/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java
+++ b/server/src/main/java/com/cloud/api/ApiAsyncJobDispatcher.java
@@ -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));
}
}
}