Skip to content

Commit 477fa85

Browse files
authored
fix(toolkit): endless wait if CDKToolkit stack is REVIEW_IN_PROGRESS (#23230)
If a `cdk bootstrap` operation is interrupted after the ChangeSet has been created, but before it is executed, the CDKToolkit stack will be left in the `REVIEW_IN_PROGRESS` state, which is a stable state until something or someone either executes or deletes the pending ChangeSet. This resulted in an endless (and silent, unless `cdk bootstrap` is executed in verbose mode) wait, as this was considered an "in progress" (aka unstable) state. This changes `REVIEW_IN_PROGRESS` to be treated as stable, while still debug-logging an indication that we are "ignoring" the existing ChangeSet.
1 parent c9fdc8a commit 477fa85

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/aws-cdk/lib/api/util/cloudformation.ts

+8
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,14 @@ export async function stabilizeStack(cfn: CloudFormation, stackName: string) {
371371
if (status.isInProgress) {
372372
debug('Stack %s has an ongoing operation in progress and is not stable (%s)', stackName, status);
373373
return undefined;
374+
} else if (status.isReviewInProgress) {
375+
// This may happen if a stack creation operation is interrupted before the ChangeSet execution starts. Recovering
376+
// from this would requiring manual intervention (deleting or executing the pending ChangeSet), and failing to do
377+
// so will result in an endless wait here (the ChangeSet wont delete or execute itself). Instead of blocking
378+
// "forever" we proceed as if the stack was existing and stable. If there is a concurrent operation that just
379+
// hasn't finished proceeding just yet, either this operation or the concurrent one may fail due to the other one
380+
// having made progress. Which is fine. I guess.
381+
debug('Stack %s is in REVIEW_IN_PROGRESS state. Considering this is a stable status (%s)', stackName, status);
374382
}
375383

376384
return stack;

packages/aws-cdk/lib/api/util/cloudformation/stack-status.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ export class StackStatus {
2626
}
2727

2828
get isInProgress(): boolean {
29-
return this.name.endsWith('_IN_PROGRESS');
29+
return this.name.endsWith('_IN_PROGRESS') && !this.isReviewInProgress;
30+
}
31+
32+
get isReviewInProgress(): boolean {
33+
return this.name === 'REVIEW_IN_PROGRESS';
3034
}
3135

3236
get isNotFound(): boolean {

0 commit comments

Comments
 (0)