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

fix(cli): diff allow specifying changeSet via cdk.json #29375

Closed
wants to merge 9 commits into from

Conversation

andreialecu
Copy link
Contributor

@andreialecu andreialecu commented Mar 6, 2024

Issue # (if applicable)

Closes #29232

Reason for this change

Allows specifying whether to use changesets via cdk.json:

"diff": {
  "changeSet": false
}

It also moves this informational message to the debug() log level:

Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)

There was a --quiet CLI argument that was not squelching it, which seemed like an oversight in the initial PR.

With many stacks, the message can be quite verbose.--verbose will reveal it, but otherwise it will be hidden

Description of changes

The default value of the change-set flag is removed and instead is handled in the diff call.

The value for changeSet in the diff call is processed in this way: setting the flag gives the value > if the flag is un-set, check the context in cdk.json > if both are un-set, default to true.

This poses a question about what flags we allow to be set in cdk.json. Here, "diff" is new in cdk.json, and "changeSet" is the first and only flag able to be set. The team can have a discussion and come to a conclusion.

Description of how you validated changes

Added tests.

Manual testing.

Checklist


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 March 6, 2024 18:03
@github-actions github-actions bot added effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK labels Mar 6, 2024
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 fails with the following errors:

❌ CLI code has changed. A maintainer must run the code through the testing pipeline (git fetch origin pull/29375/head && git push -f origin FETCH_HEAD:test-main-pipeline), then add the 'pr-linter/cli-integ-tested' label when the pipeline succeeds.

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.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@andreialecu
Copy link
Contributor Author

Exemption Request: There are integration tests here but there should be no need to touch any snapshots for this change.

@aws-cdk-automation aws-cdk-automation added pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Mar 7, 2024
@TheRealAmazonKendra TheRealAmazonKendra added the pr-linter/exempt-integ-test The PR linter will not require integ test changes label Mar 7, 2024
@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Mar 7, 2024

update

✅ Branch has been successfully updated

@mergify mergify bot temporarily deployed to test-pipeline March 7, 2024 20:41 Inactive
@TheRealAmazonKendra
Copy link
Contributor

Thank you for picking up this change. I'm running this through our test pipeline before doing a full review. I've also added the integ test exemption because, you are correct, this does not require a change to snapshots.

@scanlonp scanlonp self-assigned this Mar 8, 2024
@scanlonp
Copy link
Contributor

scanlonp commented Mar 8, 2024

@Mergifyio update

Copy link
Contributor

mergify bot commented Mar 8, 2024

update

✅ Branch has been successfully updated

@mergify mergify bot had a problem deploying to test-pipeline March 8, 2024 01:14 Failure
@TheRealAmazonKendra
Copy link
Contributor

@Mergifyio update

Copy link
Contributor

mergify bot commented Mar 8, 2024

update

✅ Branch has been successfully updated

@mergify mergify bot temporarily deployed to test-pipeline March 8, 2024 03:15 Inactive
@andreialecu
Copy link
Contributor Author

Thanks for taking a look at this @TheRealAmazonKendra

I have another PR open at #29372, which is a bit more important to me; if there was any chance someone could take a look.

@@ -341,7 +341,7 @@ async function uploadBodyParameterAndCreateChangeSet(options: PrepareChangeSetOp
const exists = (await CloudFormationStack.lookup(cfn, options.stack.stackName, false)).exists;

const executionRoleArn = preparedSdk.cloudFormationRoleArn;
options.stream.write('Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)\n');
debug('Hold on while we create a read-only change set to get a diff with accurate replacement information (use --no-change-set to use a less accurate but faster template-only diff)');
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 - thank you! This message appears too often now.

@@ -514,7 +514,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
stream: args.ci ? process.stdout : undefined,
compareAgainstProcessedTemplate: args.processed,
quiet: args.quiet,
changeSet: args['change-set'],
changeSet: configuration.settings.get(['diff', 'changeSet']) ?? args['change-set'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps this needs to be swapped so that the cdk.json setting can be overridden via the cli argument?

@@ -514,7 +514,7 @@ export async function exec(args: string[], synthesizer?: Synthesizer): Promise<n
stream: args.ci ? process.stdout : undefined,
compareAgainstProcessedTemplate: args.processed,
quiet: args.quiet,
changeSet: args['change-set'],
changeSet: configuration.settings.get(['diff', 'changeSet']) ?? args['change-set'],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Suggested change
changeSet: configuration.settings.get(['diff', 'changeSet']) ?? args['change-set'],
changeSet: args['change-set'] ?? configuration.settings.get(['diff', 'changeSet'],

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you are right about this order of operations. Only question is if there is a difference between no flag being provided and the default.

If the flag is always given a value regardless of being set, we may have to put the context first (but I will ask some others on the team about this).

@scanlonp
Copy link
Contributor

Hey @andreialecu, I have eyes on this. Will try to give a full review tomorrow, but at a glance this looks helpful and straightforward!

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@scanlonp
Copy link
Contributor

I pushed some changes so the flag and context are both respected. Will put a full explanation in the PR description.

@TheRealAmazonKendra TheRealAmazonKendra added the pr-linter/do-not-close The PR linter will not close this PR while this label is present label Mar 28, 2024
@TheRealAmazonKendra
Copy link
Contributor

Shushing up the PR bot that says changes have been requested for too long. That's on us. The bot will still want us to run the PR through our test pipeline, but now it won't close it.

@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ CLI code has changed. A maintainer must run the code through the testing pipeline (git fetch origin pull/29375/head && git push -f origin FETCH_HEAD:test-main-pipeline), then add the 'pr-linter/cli-integ-tested' label when the pipeline succeeds.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation
Copy link
Collaborator

➡️ PR build request submitted to test-main-pipeline ⬅️

A maintainer must now check the pipeline and add the pr-linter/cli-integ-tested label once the pipeline succeeds.

@comcalvi
Copy link
Contributor

One of the CLI integ tests is failing for this PR:

  ✕ cdk diff should only show verbose messages in --verbose mode
Expected substring: "Hold on while we create a read-only change set"
Received string:    "[17:46:04] CDK toolkit version: 2.139.0-rc.0 (build 9cd365e)

Could you fix this one?

@GavinZZ GavinZZ added the @aws-cdk/core Related to core CDK functionality label Jan 22, 2025
@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Jan 22, 2025
@kaizencc
Copy link
Contributor

Hi @andreialecu, I see the following outstanding issues on this PR

-- merge conflicts
-- cli integ test failing

I know a lot of these are on us :( and for that I apologize. Are you still interested in this PR or should I close it? Knowing that there will be quite a bit of migration to do, in addition to some changes the maintainer team is planning on achieving this week.

@mrgrain
Copy link
Contributor

mrgrain commented Feb 20, 2025

@kaizencc Wouldn't this also be covered by some of the generalized work you had started?

@kaizencc
Copy link
Contributor

kaizencc commented Feb 25, 2025

yes @mrgrain. i'm going to close this PR as the cli code is no longer in this repository but I think the better thing to do to support this is to eventually pick back up #32760. this is something we do want to support to be clear, but we have an idea on how to support all commands that are available in CLI but not in cdk.json

@kaizencc kaizencc closed this Feb 25, 2025
Copy link

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
@aws-cdk/core Related to core CDK functionality effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p2 pr/needs-cli-test-run This PR needs CLI tests run against it. pr-linter/do-not-close The PR linter will not close this PR while this label is present pr-linter/exempt-integ-test The PR linter will not require integ test changes pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. repeat-contributor [Pilot] contributed between 3-5 PRs to the CDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cli: diff --change-set flag not configurable via cdk.json
9 participants