aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSmokowski, Steven <steve.smokowski@att.com>2019-06-14 09:12:10 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-06-14 10:22:29 -0400
commite29b04bca6367c14fdbd403bbd275e6c8c10fa60 (patch)
tree737376817c0c143992691f1ff74dbcb583f09c6e
parent1f8aa8ef6deade96a53fa57c28d1aacab6cf7e5e (diff)
fix delete stack error not propogating
Update logic to properly format rollback error messages Change-Id: I66ad4fd78758661be297810f393e6da759daa17b Issue-ID: SO-2014 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java66
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java29
-rw-r--r--bpmn/pom.xml2
3 files changed, 66 insertions, 31 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index c323bb699d..6db0a58e3f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -220,7 +220,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
boolean backout) throws MsoException {
stripMultiCloudInputs(stackInputs);
-
CreateStackParam createStack =
createStackParam(stackName, heatTemplate, stackInputs, timeoutMinutes, environment, files, heatFiles);
Stack currentStack = createStack(createStack, cloudSiteId, tenantId);
@@ -271,20 +270,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
}
+
protected Stack processCreateStack(String cloudSiteId, String tenantId, int timeoutMinutes, boolean backout,
Stack heatStack, CreateStackParam stackCreate, boolean keyPairCleanUp) throws MsoException {
- Stack latestStack;
+ Stack latestStack = null;
try {
latestStack = pollStackForStatus(timeoutMinutes, heatStack, CREATE_IN_PROGRESS, cloudSiteId, tenantId);
} catch (MsoException me) {
- if (!backout) {
- logger.info("Exception in Create Stack, stack deletion suppressed", me);
- } else {
- logger.info("Exception in Create Stack, stack deletion will be executed", me);
- handleUnknownCreateStackFailure(heatStack, timeoutMinutes, cloudSiteId, tenantId);
- }
- me.addContext(CREATE_STACK);
- throw me;
+ logger.error("Exception in Create Stack", me);
}
return postProcessStackCreate(latestStack, backout, timeoutMinutes, keyPairCleanUp, cloudSiteId, tenantId,
stackCreate);
@@ -292,26 +285,43 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
protected Stack postProcessStackCreate(Stack stack, boolean backout, int timeoutMinutes, boolean cleanUpKeyPair,
String cloudSiteId, String tenantId, CreateStackParam stackCreate) throws MsoException {
- logger.info("Performing post processing backout: {} cleanUpKeyPair: {}, stack {}", backout, cleanUpKeyPair,
- stack);
- if (!CREATE_COMPLETE.equals(stack.getStackStatus())) {
- if (cleanUpKeyPair && !Strings.isNullOrEmpty(stack.getStackStatusReason())
- && isKeyPairFailure(stack.getStackStatusReason())) {
- return handleKeyPairConflict(cloudSiteId, tenantId, stackCreate, timeoutMinutes, backout, stack);
- }
- if (!backout) {
- logger.info("Status is not CREATE_COMPLETE, stack deletion suppressed");
- throw new StackCreationException("Stack rollback suppressed, stack not deleted");
+ if (stack == null) {
+ throw new StackCreationException("Unknown Error in Stack Creation");
+ } else {
+ logger.info("Performing post processing backout: {} cleanUpKeyPair: {}, stack {}", backout, cleanUpKeyPair,
+ stack);
+ if (!CREATE_COMPLETE.equals(stack.getStackStatus())) {
+ if (cleanUpKeyPair && !Strings.isNullOrEmpty(stack.getStackStatusReason())
+ && isKeyPairFailure(stack.getStackStatusReason())) {
+ return handleKeyPairConflict(cloudSiteId, tenantId, stackCreate, timeoutMinutes, backout, stack);
+ }
+ if (!backout) {
+ logger.info("Status is not CREATE_COMPLETE, stack deletion suppressed");
+ throw new StackCreationException("Stack rollback suppressed, stack not deleted");
+ } else {
+ logger.info("Status is not CREATE_COMPLETE, stack deletion will be executed");
+ String errorMessage = "Stack Creation Failed Openstack Status: " + stack.getStackStatus()
+ + " Status Reason: " + stack.getStackStatusReason();
+ try {
+ Stack deletedStack =
+ handleUnknownCreateStackFailure(stack, timeoutMinutes, cloudSiteId, tenantId);
+ errorMessage = errorMessage + " , Rollback of Stack Creation completed with status: "
+ + deletedStack.getStackStatus() + " Status Reason: "
+ + deletedStack.getStackStatusReason();
+ } catch (MsoException e) {
+ logger.error("Sync Error Deleting Stack during rollback", e);
+ if (e instanceof StackRollbackException) {
+ errorMessage = errorMessage + e.getMessage();
+ } else {
+ errorMessage = errorMessage + " , Rollback of Stack Creation failed with sync error: "
+ + e.getMessage();
+ }
+ }
+ throw new StackCreationException(errorMessage);
+ }
} else {
- logger.info("Status is not CREATE_COMPLETE, stack deletion will be executed");
- Stack deletedStack = handleUnknownCreateStackFailure(stack, timeoutMinutes, cloudSiteId, tenantId);
- throw new StackCreationException("Stack Creation Failed Openstack Status: " + stack.getStackStatus()
- + " Status Reason: " + stack.getStackStatusReason()
- + " , Rollback of Stack Creation completed with status: " + deletedStack.getStackStatus()
- + " Status Reason: " + deletedStack.getStackStatusReason());
+ return stack;
}
- } else {
- return stack;
}
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index 6673e69a09..de55e85ad6 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -188,6 +188,31 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
}
@Test
+ public final void postProcessStackCreate_Backout_True_Delete_Fail_Test() throws MsoException, IOException {
+ Stack stack = new Stack();
+ stack.setId("id");
+ stack.setStackName("stackName");
+ stack.setStackStatus("CREATE_IN_PROGRESS");
+ stack.setStackStatusReason("Stack Finished");
+
+ Stack deletedStack = new Stack();
+ deletedStack.setId("id");
+ deletedStack.setStackName("stackName");
+ deletedStack.setStackStatus("DELETE_COMPLETE");
+ deletedStack.setStackStatusReason("Stack Deleted");
+
+ CreateStackParam createStackParam = new CreateStackParam();
+ createStackParam.setStackName("stackName");
+ doThrow(new MsoOpenstackException(500, "Error In Delete", "Error In Delete")).when(heatUtils)
+ .handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
+ exceptionRule.expect(MsoException.class);
+ exceptionRule.expectMessage(
+ "Stack Creation Failed Openstack Status: CREATE_IN_PROGRESS Status Reason: Stack Finished , Rollback of Stack Creation failed with sync error: Error In Delete");
+ heatUtils.postProcessStackCreate(stack, true, 120, false, cloudSiteId, tenantId, createStackParam);
+ Mockito.verify(heatUtils, times(1)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
+ }
+
+ @Test
public final void postProcessStackCreate_Keypair_True_Test() throws MsoException, IOException {
Stack stack = new Stack();
stack.setId("id");
@@ -375,12 +400,12 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
doThrow(new StackCreationException("Error")).when(heatUtils).pollStackForStatus(120, stack,
"CREATE_IN_PROGRESS", cloudSiteId, tenantId);
- doReturn(deletedStack).when(heatUtils).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
exceptionRule.expect(MsoException.class);
exceptionRule.expectMessage("Error");
heatUtils.processCreateStack(cloudSiteId, tenantId, 120, true, stack, createStackParam, true);
Mockito.verify(heatUtils, times(1)).pollStackForStatus(120, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId);
- Mockito.verify(heatUtils, times(1)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
+ Mockito.verify(heatUtils, times(1)).postProcessStackCreate(stack, true, 120, true, cloudSiteId, tenantId,
+ createStackParam);
}
diff --git a/bpmn/pom.xml b/bpmn/pom.xml
index f09cfaa38c..65af2fd8d5 100644
--- a/bpmn/pom.xml
+++ b/bpmn/pom.xml
@@ -24,7 +24,7 @@
<xmlunit.version>2.4.0</xmlunit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <sdnc.northbound.version>1.5.2-SNAPSHOT</sdnc.northbound.version>
+ <sdnc.northbound.version>1.5.2</sdnc.northbound.version>
<appc.client.version>1.6.0-SNAPSHOT</appc.client.version>
</properties>