Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): logging can be corked #25644

Merged
merged 7 commits into from
May 19, 2023
Merged

feat(cli): logging can be corked #25644

merged 7 commits into from
May 19, 2023

Conversation

kaizencc
Copy link
Contributor

@kaizencc kaizencc commented May 18, 2023

🍾

This PR extends #25536 by fixing issues with logging.

  • Asset building and publishing are now completely separate tasks, so there is never a need for the "Building and Publishing" message in cdk-assets. I've removed a good chunk of unnecessary private props in AssetPublisher and now we simply print Building when building an asset and Publishing when publishing an asset. No combos anymore.
  • Asset build/publish can now happen concurrently with stack deployments when there are no dependencies between the two, but if --require-approval is set (which it is by default), sensitive stack deployments prompt the user for a y/n response before deployment. Additional asset related messages may come in at this time, cluttering the log. The solution here is to implement a cork that is turned on when prompting the user and turned off after user input. When using the helper function withCorkedLogging(callback), logs will instead be stored in memory and released when the cork is popped.

Testing:

There's not a great way to test these changes in code since they should only affect logging. Instead, I hope the following photos suffice:

Before the lock change, logging looked like this:
Screen Shot 2023-05-18 at 4 59 35 PM

Now it looks like this in the same scenario:

Screen Shot 2023-05-18 at 4 49 39 PM

The screenshots also show the logs that say Building and Publishing separately rather than Building and Publishing as it did before.


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

@aws-cdk-automation aws-cdk-automation requested a review from a team May 18, 2023 21:01
@gitpod-io
Copy link

gitpod-io bot commented May 18, 2023

@github-actions github-actions bot added the p2 label May 18, 2023
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label May 18, 2023
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label May 18, 2023
@kaizencc kaizencc added pr-linter/exempt-readme The PR linter will not require README changes pr-linter/exempt-test The PR linter will not require test changes pr-linter/exempt-integ-test The PR linter will not require integ test changes labels May 18, 2023
@@ -7,6 +7,11 @@ const { stdout, stderr } = process;

type WritableFactory = () => Writable;

// LOG_LOCK is an array rather than a boolean because it needs to be modified by other
// parts of the CLI and imported variables are always immutable.
export const LOG_LOCK = [false];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is almost certainly the hackiest thing i've ever come up with. whats the better way to do something like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok i thought of a better way immediately lol

@rix0rrr rix0rrr added the pr/do-not-merge This PR should not be merged at this time. label May 19, 2023
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

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

I like the solution! Needs some changes before it can be merged but conditionally approved

packages/aws-cdk/lib/logging.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Outdated Show resolved Hide resolved
packages/aws-cdk/lib/cdk-toolkit.ts Outdated Show resolved Hide resolved
@kaizencc kaizencc changed the title feat(cli): logging can be locked feat(cli): logging can be corked May 19, 2023
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: b86faef
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@kaizencc kaizencc added pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested and removed pr/needs-cli-test-run This PR needs CLI tests run against it. pr/do-not-merge This PR should not be merged at this time. labels May 19, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review May 19, 2023 18:24

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@mergify
Copy link
Contributor

mergify bot commented May 19, 2023

Thank you for contributing! Your pull request will be updated from main 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 0643020 into main May 19, 2023
@mergify mergify bot deleted the conroy/clifix branch May 19, 2023 18:25
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. p2 pr-linter/cli-integ-tested Assert that any CLI changes have been integ tested pr-linter/exempt-integ-test The PR linter will not require integ test changes 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.

3 participants