@@ -354,7 +354,7 @@ public void waitForCompletion(AbstractStackHandler stack, String until) throws E
354
354
waitForCompletion (stack , until , null );
355
355
}
356
356
357
- public void waitForCompletion (AbstractStackHandler stack , String until , String exception ) throws Exception {
357
+ public void waitForCompletion (AbstractStackHandler stack , String until , String throwExceptionThen ) throws Exception {
358
358
//operationFinishedMutex.release();
359
359
logger .info ("Waiting for {} for stack {}" , until , stack .getName ());
360
360
List <String > untilList = Arrays .asList (until );
@@ -370,7 +370,7 @@ public void waitForCompletion(AbstractStackHandler stack, String until, String e
370
370
else
371
371
if (stackSummary .getStackStatus ().startsWith (until )) {
372
372
stop = true ;
373
- } else if (exception != null && stackSummary .getStackStatus ().startsWith (exception )) {
373
+ } else if (throwExceptionThen != null && stackSummary .getStackStatus ().startsWith (throwExceptionThen )) {
374
374
String errorMessage = String .format ("Stack %s not reached the state %s: %s" , stack .getName (), until , stackSummary .getStackStatusReason ());
375
375
throw new Exception (errorMessage );
376
376
} else {
@@ -729,11 +729,18 @@ public String createStack(AbstractStackHandler stack, boolean allowUpdate) throw
729
729
waitForCompletion (stack , "CREATE_COMPLETE" );
730
730
stack .setId (stackSummary .getStackId ());
731
731
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" )) {
737
744
logger .info ("A stack {} with DELETE_IN_PROGRESS found" , stack .getName ());
738
745
waitForCompletion (stack , "DELETE_COMPLETE" );
739
746
}
0 commit comments