From 24792a171f4e607bf8e3a1366fe820146e420de5 Mon Sep 17 00:00:00 2001 From: Harrison Cannon Date: Sun, 22 Aug 2021 23:17:36 +0000 Subject: [PATCH 1/6] fix(cli): Increased 'resourcesTotal' for UPDATE_COMPLETE events --- packages/aws-cdk/lib/api/deploy-stack.ts | 5 ++++- .../lib/api/util/cloudformation/stack-activity-monitor.ts | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts index df811e39587be..c720765cc9d20 100644 --- a/packages/aws-cdk/lib/api/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deploy-stack.ts @@ -284,8 +284,11 @@ export async function deployStack(options: DeployStackOptions): Promise Date: Sun, 22 Aug 2021 23:18:32 +0000 Subject: [PATCH 2/6] docs(CONTRIBUTING): Fix 'Step 4: Pull Request' link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8c85b5a2ce259..31f902a285c94 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,7 +18,7 @@ let us know if it's not up-to-date (even better, submit a PR with your correcti - [Step 1: Find something to work on](#step-1-find-something-to-work-on) - [Step 2: Design (optional)](#step-2-design-optional) - [Step 3: Work your Magic](#step-3-work-your-magic) - - [Step 4: Pull Request](#step-5-pull-request) + - [Step 4: Pull Request](#step-4-pull-request) - [Step 5: Merge](#step-5-merge) - [Breaking Changes](#breaking-changes) - [Documentation](#documentation) From c0c057b9e808cc3143d1f23a21dd614264c298c6 Mon Sep 17 00:00:00 2001 From: Harrison Cannon Date: Mon, 23 Aug 2021 00:27:35 +0000 Subject: [PATCH 3/6] fix(cli): Modified code to pass test --- packages/aws-cdk/lib/api/deploy-stack.ts | 2 +- .../lib/api/util/cloudformation/stack-activity-monitor.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts index c720765cc9d20..0ab1db05632c8 100644 --- a/packages/aws-cdk/lib/api/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deploy-stack.ts @@ -288,7 +288,7 @@ export async function deployStack(options: DeployStackOptions): Promise Date: Mon, 23 Aug 2021 00:27:54 +0000 Subject: [PATCH 4/6] fix(cli): Modified test to allow for extra spacing --- .../test/api/stack-activity-monitor.test.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/aws-cdk/test/api/stack-activity-monitor.test.ts b/packages/aws-cdk/test/api/stack-activity-monitor.test.ts index 7a1037581c94e..c76ddda1ceb00 100644 --- a/packages/aws-cdk/test/api/stack-activity-monitor.test.ts +++ b/packages/aws-cdk/test/api/stack-activity-monitor.test.ts @@ -32,7 +32,7 @@ test('prints 0/4 progress report, when addActivity is called with an "IN_PROGRES }); }); - expect(output[0].trim()).toStrictEqual(`0/4 |${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`); + expect(output[0].trim()).toStrictEqual(`0/4 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`); }); test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COMPLETE" ResourceStatus', () => { @@ -56,7 +56,7 @@ test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COM }); }); - expect(output[0].trim()).toStrictEqual(`1/4 |${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`); + expect(output[0].trim()).toStrictEqual(`1/4 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`); }); test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COMPLETE_CLEAN_IN_PROGRESS" ResourceStatus', () => { @@ -80,7 +80,7 @@ test('prints 1/4 progress report, when addActivity is called with an "UPDATE_COM }); }); - expect(output[0].trim()).toStrictEqual(`1/4 |${HUMAN_TIME} | ${green('UPDATE_COMPLETE_CLEA')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`); + expect(output[0].trim()).toStrictEqual(`1/4 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE_CLEA')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`); }); @@ -105,7 +105,7 @@ test('prints 1/4 progress report, when addActivity is called with an "ROLLBACK_C }); }); - expect(output[0].trim()).toStrictEqual(`1/4 |${HUMAN_TIME} | ${yellow('ROLLBACK_COMPLETE_CL')} | AWS::CloudFormation::Stack | ${yellow(bold('stack1'))}`); + expect(output[0].trim()).toStrictEqual(`1/4 | ${HUMAN_TIME} | ${yellow('ROLLBACK_COMPLETE_CL')} | AWS::CloudFormation::Stack | ${yellow(bold('stack1'))}`); }); test('prints 0/4 progress report, when addActivity is called with an "UPDATE_FAILED" ResourceStatus', () => { @@ -129,7 +129,7 @@ test('prints 0/4 progress report, when addActivity is called with an "UPDATE_FAI }); }); - expect(output[0].trim()).toStrictEqual(`0/4 |${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`); + expect(output[0].trim()).toStrictEqual(`0/4 | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`); }); @@ -178,9 +178,9 @@ test('does not print "Failed Resources:" list, when all deployments are successf }); expect(output.length).toStrictEqual(3); - expect(output[0].trim()).toStrictEqual(`0/2 |${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`); - expect(output[1].trim()).toStrictEqual(`1/2 |${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`); - expect(output[2].trim()).toStrictEqual(`2/2 |${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack2'))}`); + expect(output[0].trim()).toStrictEqual(`0/2 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`); + expect(output[1].trim()).toStrictEqual(`1/2 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack1'))}`); + expect(output[2].trim()).toStrictEqual(`2/2 | ${HUMAN_TIME} | ${green('UPDATE_COMPLETE ')} | AWS::CloudFormation::Stack | ${green(bold('stack2'))}`); }); test('prints "Failed Resources:" list, when at least one deployment fails', () => { @@ -217,8 +217,8 @@ test('prints "Failed Resources:" list, when at least one deployment fails', () = }); expect(output.length).toStrictEqual(4); - expect(output[0].trim()).toStrictEqual(`0/2 |${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`); - expect(output[1].trim()).toStrictEqual(`0/2 |${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`); + expect(output[0].trim()).toStrictEqual(`0/2 | ${HUMAN_TIME} | ${reset('IN_PROGRESS ')} | AWS::CloudFormation::Stack | ${reset(bold('stack1'))}`); + expect(output[1].trim()).toStrictEqual(`0/2 | ${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`); expect(output[2].trim()).toStrictEqual('Failed resources:'); expect(output[3].trim()).toStrictEqual(`${HUMAN_TIME} | ${red('UPDATE_FAILED ')} | AWS::CloudFormation::Stack | ${red(bold('stack1'))}`); }); From b9c12f3d1b2b19ae9c185c0ffa14b35bcad92f28 Mon Sep 17 00:00:00 2001 From: HariboDev Date: Sat, 11 Sep 2021 16:40:51 +0100 Subject: [PATCH 5/6] docs(CONTRIBUTING): Fix 'Step 2: Design' link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 31f902a285c94..11e8e2a8936eb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ let us know if it's not up-to-date (even better, submit a PR with your correcti - [Getting Started](#getting-started) - [Pull Requests](#pull-requests) - [Step 1: Find something to work on](#step-1-find-something-to-work-on) - - [Step 2: Design (optional)](#step-2-design-optional) + - [Step 2: Design (optional)](#step-2-design) - [Step 3: Work your Magic](#step-3-work-your-magic) - [Step 4: Pull Request](#step-4-pull-request) - [Step 5: Merge](#step-5-merge) From 6cc6aa40b6155987fb759b1484233ab6db22cb07 Mon Sep 17 00:00:00 2001 From: HariboDev Date: Sat, 11 Sep 2021 16:41:27 +0100 Subject: [PATCH 6/6] fix(cli) Updated comments to reflect functionality of code --- packages/aws-cdk/lib/api/deploy-stack.ts | 3 +-- .../lib/api/util/cloudformation/stack-activity-monitor.ts | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/aws-cdk/lib/api/deploy-stack.ts b/packages/aws-cdk/lib/api/deploy-stack.ts index 985b8a931548e..0990b8f415a77 100644 --- a/packages/aws-cdk/lib/api/deploy-stack.ts +++ b/packages/aws-cdk/lib/api/deploy-stack.ts @@ -334,8 +334,7 @@ async function prepareAndExecuteChangeSet( // eslint-disable-next-line max-len const changeSetLength: number = (changeSetDescription.Changes ?? []).length; const monitor = options.quiet ? undefined : StackActivityMonitor.withDefaultPrinter(cfn, deployName, stackArtifact, { - // +2 for the COMPLETE event emitted from updates. - // +1 for the COMPLETE event emitted from creates. + // +1 for the extra event emitted from updates. resourcesTotal: cloudFormationStack.exists ? changeSetLength + 1 : changeSetLength, progress: options.progress, changeSetCreationTime: changeSetDescription.CreationTime, diff --git a/packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts b/packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts index 0475b818a0e41..73075a41fee27 100644 --- a/packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts +++ b/packages/aws-cdk/lib/api/util/cloudformation/stack-activity-monitor.ts @@ -384,6 +384,8 @@ abstract class ActivityPrinterBase implements IActivityPrinter { protected readonly stream: NodeJS.WriteStream; constructor(protected readonly props: PrinterProps) { + // +1 because the stack also emits a "COMPLETE" event at the end, and that wasn't + // counted yet. This makes it line up with the amount of events we expect. this.resourcesTotal = props.resourcesTotal ? props.resourcesTotal + 1 : undefined; // How many digits does this number take to represent?