Skip to content

feat(cli): add message when resource is hotswapped#18058

Merged
mergify[bot] merged 5 commits intoaws:masterfrom
corymhall:corymhall/hotswap-complete
Dec 17, 2021
Merged

feat(cli): add message when resource is hotswapped#18058
mergify[bot] merged 5 commits intoaws:masterfrom
corymhall:corymhall/hotswap-complete

Conversation

@corymhall
Copy link
Copy Markdown
Contributor

Add additional messages to indicate that a hotswap deployment is
occurring (or not) along with what resources are being hotswapped.

fix #17778


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

Add additional messages to indicate that a hotswap deployment is
occurring (or not) along with what resources are being hotswapped.

fix #17778
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Dec 16, 2021

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Dec 16, 2021
@corymhall corymhall requested a review from skinny85 December 16, 2021 18:26
@github-actions github-actions bot added the package/tools Related to AWS CDK Tools or CLI label Dec 16, 2021
Copy link
Copy Markdown
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @corymhall! A few comments on the first pass 🙂.

// if we can skip deployment and we are performing a hotswap, let the user know
// that no hotswap deployment happened
if (options.hotswap) {
print(`\n ${ICON} %s\n`, colors.bold('no hotswap deployment'));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this message needs a little polish... We have to make sure it's clear that the deployment isn't happening, because no changes were detected.

Something like:

Suggested change
print(`\n ${ICON} %s\n`, colors.bold('no hotswap deployment'));
print(`\n ${ICON} %s\n`, colors.bold('deployment skipped - no changes were detected (use --force to override)'));

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

public async apply(sdk: ISDK): Promise<any> {
// not passing the optional properties leaves them unchanged
const name = this.stepFunctionResource.stateMachineArn.split(':')[6];
print(` ${ICON} hotswapping state machine: %s`, colors.bold(name));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the fact that we're putting these print statements inside of the hotswap operations themselves.

How about we change the return type of the apply() method in HotswapOperation to return the identifier of the hotswapped resource (or maybe even resources), and then the print() logic will only be inside hotswap-deployments.ts?

I feel like that's a nicer separation of concerns than having the print() statements here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these back to hotswap-deployments as we discussed.

Copy link
Copy Markdown
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Minor comments on the style, but otherwise looks awesome!

@skinny85 skinny85 changed the title feat(cli): add messages to hotswap deployments feat(cli): add message when resource is hotswapped Dec 17, 2021
@skinny85 skinny85 assigned skinny85 and unassigned rix0rrr Dec 17, 2021
@skinny85 skinny85 added the pr-linter/exempt-readme The PR linter will not require README changes label Dec 17, 2021
@skinny85 skinny85 added the pr-linter/exempt-test The PR linter will not require test changes label Dec 17, 2021
Co-authored-by: Adam Ruka <adamruka85@gmail.com>
Copy link
Copy Markdown
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks @corymhall!

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 17, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit e828c22 into aws:master Dec 17, 2021
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Dec 17, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: f1c771f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@eladb
Copy link
Copy Markdown
Contributor

eladb commented Dec 19, 2021

Looks good. For next time, when doing UI changes, I would recommend sharing a screenshot or screencast of how this looks in the PR description or comment.

@skinny85
Copy link
Copy Markdown
Contributor

To be fair, Cory did actually share a gif of the experience with us, it was just in our private Slack 🙂.

@eladb
Copy link
Copy Markdown
Contributor

eladb commented Dec 20, 2021

Sharing is caring

mergify bot pushed a commit that referenced this pull request Dec 28, 2021
This extends the existing hotswapping support for Lambda Functions to also work for Versions and Aliases.

Implementation-wise, this required quite a bit of changes, as Versions are immutable in CloudFormation,
and the only way you can change them is by replacing them;
so, we had to add the notion of replacement changes to our hotswapping logic
(as, up to this point, they were simply a pair of "delete" and "add" changes,
which would result in hotswapping determining it can't proceed,
and falling back to a full CloudFormation deployment).

I also modified the main hotswapping algorithm:
now, a resource change is considered non-hotswappable if all detectors return `REQUIRES_FULL_DEPLOYMENT` for it;
if at least one detector returns `IRRELEVANT`, we ignore this change.
This allows us to get rid of the awkward `EmptyHotswapOperation` that we had to use before in these situations.

I also made a few small tweaks to the printing messages added in #18058:
I no longer prefix them with the name of the service,
as now hotswapping can affect different resource types, and it looked a bit awkward with that prefix present.

Fixes #17043

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Add additional messages to indicate that a hotswap deployment is
occurring (or not) along with what resources are being hotswapped.

fix aws#17778


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
…8145)

This extends the existing hotswapping support for Lambda Functions to also work for Versions and Aliases.

Implementation-wise, this required quite a bit of changes, as Versions are immutable in CloudFormation,
and the only way you can change them is by replacing them;
so, we had to add the notion of replacement changes to our hotswapping logic
(as, up to this point, they were simply a pair of "delete" and "add" changes,
which would result in hotswapping determining it can't proceed,
and falling back to a full CloudFormation deployment).

I also modified the main hotswapping algorithm:
now, a resource change is considered non-hotswappable if all detectors return `REQUIRES_FULL_DEPLOYMENT` for it;
if at least one detector returns `IRRELEVANT`, we ignore this change.
This allows us to get rid of the awkward `EmptyHotswapOperation` that we had to use before in these situations.

I also made a few small tweaks to the printing messages added in aws#18058:
I no longer prefix them with the name of the service,
as now hotswapping can affect different resource types, and it looked a bit awkward with that prefix present.

Fixes aws#17043

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. package/tools Related to AWS CDK Tools or CLI pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(cli): no message indicates that a hotswap happened

5 participants