Skip to content

Commit

Permalink
chore: delete integration stacks serially
Browse files Browse the repository at this point in the history
This is a follow-up to #14505 which in retrospect wasn't complete.

The list of stacks was ordered properly, but since all stacks were being
deleted in parallel this didn't actually solve the race condition.

Delete stacks in series instead.
  • Loading branch information
rix0rrr committed May 3, 2021
1 parent 39d4e96 commit 55f3c32
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/aws-cdk/test/integ/helpers/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export class AwsClients {
public async deleteStacks(...stackNames: string[]) {
if (stackNames.length === 0) { return; }

// We purposely do all stacks serially, because they've been ordered
// to do the bootstrap stack last.
for (const stackName of stackNames) {
await this.cloudFormation('updateTerminationProtection', {
EnableTerminationProtection: false,
Expand All @@ -53,19 +55,17 @@ export class AwsClients {
await this.cloudFormation('deleteStack', {
StackName: stackName,
});
}

await retry(this.output, `Deleting ${stackNames}`, retry.forSeconds(600), async () => {
for (const stackName of stackNames) {
await retry(this.output, `Deleting ${stackName}`, retry.forSeconds(600), async () => {
const status = await this.stackStatus(stackName);
if (status !== undefined && status.endsWith('_FAILED')) {
throw retry.abort(new Error(`'${stackName}' is in state '${status}'`));
}
if (status !== undefined) {
throw new Error(`Delete of '${stackName}' not complete yet`);
}
}
});
});
}
}

public async stackStatus(stackName: string): Promise<string | undefined> {
Expand Down

0 comments on commit 55f3c32

Please sign in to comment.