Skip to content

Commit

Permalink
chore: delete integration stacks serially (aws#14506)
Browse files Browse the repository at this point in the history
This is a follow-up to aws#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.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored and hollanddd committed Aug 26, 2021
1 parent 16c1932 commit 6c931d6
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 6c931d6

Please sign in to comment.