aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils/src/main
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2018-12-20 08:38:23 -0800
committerEric Multanen <eric.w.multanen@intel.com>2018-12-20 08:43:45 -0800
commit8521170839c30e240eac51b0daa5544293dac7b3 (patch)
tree23d5b824bd45686422f376bbd808f48e02a5e510 /adapters/mso-adapter-utils/src/main
parent522bb0f585c7248a99c26cc10a5bbc0954e27e82 (diff)
Fixup multicloud log exceptions and error cases
Fix log calls which would have an exception. Throw and mso exception when call to multicloud fails to create a stack. Change-Id: Ib103c6f4420e444734bbb715699eb57ffc110925 Issue-ID: SO-1336 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
Diffstat (limited to 'adapters/mso-adapter-utils/src/main')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java41
1 files changed, 24 insertions, 17 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index 73e0da1cd9..0e37ce3552 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -205,17 +205,24 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
createInfo.setName(stackName);
MulticloudCreateResponse multicloudResponseBody = null;
- if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) {
+ if (response.hasEntity()) {
multicloudResponseBody = getCreateBody((java.io.InputStream)response.getEntity());
+ }
+ if (response.getStatus() == Response.Status.CREATED.getStatusCode() && response.hasEntity()) {
createInfo.setCanonicalName(stackName + "/" + multicloudResponseBody.getWorkloadId());
if (logger.isDebugEnabled()) {
logger.debug("Multicloud Create Response Body: " + multicloudResponseBody);
}
return getStackStatus(cloudSiteId, tenantId, createInfo.getCanonicalName(), pollForCompletion, timeoutMinutes, backout);
} else {
- createInfo.setStatus(HeatStatus.FAILED);
- createInfo.setStatusMessage(response.getStatusInfo().getReasonPhrase());
- return createInfo;
+ StringBuilder stackErrorStatusReason = new StringBuilder(response.getStatusInfo().getReasonPhrase());
+ if (null != multicloudResponseBody) {
+ stackErrorStatusReason.append(multicloudResponseBody.toString());
+ }
+ MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString());
+ me.addContext(CREATE_STACK);
+ alarmLogger.sendAlarm(HEAT_ERROR, MsoAlarmLogger.CRITICAL, me.getContextMessage());
+ throw me;
}
}
@@ -383,7 +390,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
if (pollTimeout <= 0) {
// Note that this should not occur, since there is a timeout specified
// in the Openstack (multicloud?) call.
- logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout"));
+ logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId, stackInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError, "Create stack timeout"));
createTimedOut = true;
break;
}
@@ -401,7 +408,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
// Cannot query the stack status. Something is wrong.
// Try to roll back the stack
if (!backout) {
- logger.warn(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed"));
+ logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack, stack deletion suppressed"));
} else {
try {
logger.debug("Create Stack error - unable to query for stack status - attempting to delete stack: " + instanceId + " - This will likely fail and/or we won't be able to query to see if delete worked");
@@ -415,7 +422,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus());
if (HeatStatus.DELETING.equals(queryInfo.getStatus())) {
if (deletePollTimeout <= 0) {
- logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId,
+ logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId,
queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError,
"Rollback: DELETE stack timeout"));
break;
@@ -433,12 +440,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
} catch (Exception e3) {
// Just log this one. We will report the original exception.
- logger.error(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query"));
+ logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e3, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack on error on query"));
}
}
} catch (Exception e2) {
// Just log this one. We will report the original exception.
- logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack"));
+ logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack: Nested exception rolling back stack"));
}
}
@@ -449,12 +456,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
if (!HeatStatus.CREATED.equals(stackInfo.getStatus())) {
- logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack error: Polling complete with non-success status: "
+ logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack error: Polling complete with non-success status: "
+ stackInfo.getStatus () + ", " + stackInfo.getStatusMessage(), "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error"));
// Rollback the stack creation, since it is in an indeterminate state.
if (!backout) {
- logger.warn(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed"));
+ logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion suppressed", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion suppressed"));
}
else
{
@@ -469,7 +476,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
logger.debug("Deleting " + instanceId + ", status: " + queryInfo.getStatus());
if (HeatStatus.DELETING.equals(queryInfo.getStatus())) {
if (deletePollTimeout <= 0) {
- logger.error(String.format("%d %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT, cloudSiteId, tenantId, instanceId,
+ logger.error(String.format("%s %s %s %s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_TIMEOUT.toString(), cloudSiteId, tenantId, instanceId,
queryInfo.getStatus(), "", "", MsoLogger.ErrorCode.AvailabilityError,
"Rollback: DELETE stack timeout"));
break;
@@ -483,14 +490,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
continue;
} else {
//got a status other than DELETE_IN_PROGRESS or DELETE_COMPLETE - so break and evaluate
- logger.warn(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED"));
+ logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, stack deletion FAILED", "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Create Stack error, stack deletion FAILED"));
logger.debug("Stack deletion FAILED on a rollback of a create - " + instanceId + ", status=" + queryInfo.getStatus() + ", reason=" + queryInfo.getStatusMessage());
break;
}
} catch (MsoException me2) {
// Just log this one. We will report the original exception.
logger.debug("Exception thrown trying to delete " + instanceId + " on a create->rollback: " + me2.getContextMessage(), me2);
- logger.warn(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage()));
+ logger.warn(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack errored, then stack deletion FAILED - exception thrown", "", "", MsoLogger.ErrorCode.BusinessProcesssError, me2.getContextMessage()));
}
}
StringBuilder errorContextMessage;
@@ -506,7 +513,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
}
} catch (MsoException e2) {
// shouldn't happen - but handle
- logger.error(String.format("%d %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR, "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack"));
+ logger.error(String.format("%s %s %s %s %d %s", MessageEnum.RA_CREATE_STACK_ERR.toString(), "Create Stack: Nested exception rolling back stack: " + e2, "", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in Create Stack: rolling back stack"));
}
}
MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString());
@@ -613,8 +620,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{
try {
return JSON_MAPPER.readTree(directives);
} catch (Exception e) {
- logger.error(String.format("%d %s %s %s %d %s",
- MessageEnum.RA_CREATE_STACK_ERR,
+ logger.error(String.format("%s %s %s %s %d %s",
+ MessageEnum.RA_CREATE_STACK_ERR.toString(),
"Create Stack: " + e, "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
"Exception in Create Stack: Invalid JSON format of directives" + directives));