Skip to content

Commit 95376dc

Browse files
committed
Minor changes
1 parent 5fafe3e commit 95376dc

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/main/java/org/hobbit/awscontroller/AWSController.java

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ public void waitForCompletion(AbstractStackHandler stack, String until) throws E
354354
waitForCompletion(stack, until, null);
355355
}
356356

357-
public void waitForCompletion(AbstractStackHandler stack, String until, String exception) throws Exception {
357+
public void waitForCompletion(AbstractStackHandler stack, String until, String throwExceptionThen) throws Exception {
358358
//operationFinishedMutex.release();
359359
logger.info("Waiting for {} for stack {}", until, stack.getName());
360360
List<String> untilList = Arrays.asList(until);
@@ -370,7 +370,7 @@ public void waitForCompletion(AbstractStackHandler stack, String until, String e
370370
else
371371
if (stackSummary.getStackStatus().startsWith(until)) {
372372
stop = true;
373-
} else if (exception != null && stackSummary.getStackStatus().startsWith(exception)) {
373+
} else if (throwExceptionThen != null && stackSummary.getStackStatus().startsWith(throwExceptionThen)) {
374374
String errorMessage = String.format("Stack %s not reached the state %s: %s", stack.getName(), until, stackSummary.getStackStatusReason());
375375
throw new Exception(errorMessage);
376376
} else {
@@ -729,11 +729,18 @@ public String createStack(AbstractStackHandler stack, boolean allowUpdate) throw
729729
waitForCompletion(stack, "CREATE_COMPLETE");
730730
stack.setId(stackSummary.getStackId());
731731
logger.info("Stack {} created", stack.getName());
732-
} else if (stackSummary.getStackStatus().startsWith("ROLLBACK_")) {
733-
logger.info("A rollbacked stack found. Deleting: {}", stack.getName());
734-
deleteStack(stack);
735-
//AWSController.waitForCompletion(stack, "DELETE_COMPLETE");
736-
} else if (stackSummary.getStackStatus().equals("DELETE_IN_PROGRESS")) {
732+
} else if (stackSummary.getStackStatus().contains("ROLLBACK_")) {
733+
if(stackSummary.getStackStatus().endsWith("ROLLBACK_FAILED")) {
734+
logger.info("A rollbacked stack found. Deleting: {}", stack.getName());
735+
deleteStack(stack);
736+
}
737+
} else if (stackSummary.getStackStatus().startsWith("UPDATE_")) {
738+
if(stackSummary.getStackStatus().endsWith("_FAILED")) {
739+
logger.info("A rollbacked stack found. Deleting: {}", stack.getName());
740+
deleteStack(stack);
741+
}
742+
stack.setId(stackSummary.getStackId());
743+
} else if (stackSummary.getStackStatus().equals("DELETE_IN_PROGRESS")) {
737744
logger.info("A stack {} with DELETE_IN_PROGRESS found", stack.getName());
738745
waitForCompletion(stack, "DELETE_COMPLETE");
739746
}

0 commit comments

Comments
 (0)