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): warn of non-existent stacks in cdk destroy #32636

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

go-to-k
Copy link
Contributor

@go-to-k go-to-k commented Dec 22, 2024

Issue # (if applicable)

Closes #32545.
Fixes #27179.

Reason for this change

Once this PR was reverted by other cli-integ test regression.

But the regression was apparently due to a cause unrelated to that PR. That has been corrected in this PR (see: https://github.com/aws/aws-cdk/blob/v2.173.1/packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/cli.integtest.ts#L286-L291).

Therefore, I submit the same PR again.

Description of changes

This PR for cli is to warn if stacks with wrong cases (=not exist) specified in cdk destroy.

* It does not display the message Are you sure you want to delete: if there is no matching stack.
* Even if the stack does not exist, cdk destroy will not fail, it will just print a warning.

Actual Outputs:

cdk-destroy-warn

Describe any new or updated permissions being added

<!— What new or updated IAM permissions are needed to support the changes being introduced ? -->

Nothing.

Description of how you validated changes

Both of unit tests and cli-integ tests.

The changes were already approved in the last PR.

Checklist


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

@github-actions github-actions bot added bug This issue is a bug. effort/medium Medium work item – several days of effort p2 labels Dec 22, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team December 22, 2024 19:14
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label Dec 22, 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 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 Dec 22, 2024
Copy link

codecov bot commented Dec 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.83%. Comparing base (5735e9e) to head (ad25a96).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #32636      +/-   ##
==========================================
+ Coverage   80.54%   80.83%   +0.28%     
==========================================
  Files         106      106              
  Lines        6954     6975      +21     
  Branches     1287     1292       +5     
==========================================
+ Hits         5601     5638      +37     
+ Misses       1175     1158      -17     
- Partials      178      179       +1     
Flag Coverage Δ
suite.unit 80.83% <100.00%> (+0.28%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
packages/aws-cdk 80.83% <100.00%> (+0.28%) ⬆️

@go-to-k go-to-k changed the title feat(cli): warn of non-existent stacks in cdk destroy feat(cli): warn of non-existent stacks in cdk destroy Dec 22, 2024
@go-to-k
Copy link
Contributor Author

go-to-k commented Dec 23, 2024

Exemption Request:

The change was already approved in the last PR.

Features must contain a change to a README file.

This PR just outputs warnings so I didn't change README.

Features must contain a change to an integration test file and the resulting snapshot.

No snapshot is needed because this PR is for CLI. And I'm waiting for cli-integ-tests to run.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Dec 23, 2024
@go-to-k go-to-k marked this pull request as ready for review December 23, 2024 10:14
@go-to-k go-to-k requested a review from a team as a code owner December 23, 2024 10:14
@mrgrain mrgrain removed the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Dec 23, 2024
Copy link
Contributor

@mrgrain mrgrain left a comment

Choose a reason for hiding this comment

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

See inline comments. We also need tests for the new suggested stacks messages.

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
@mrgrain
Copy link
Contributor

mrgrain commented Dec 23, 2024

Exemption Request:

The change was already approved in the last PR.

Features must contain a change to a README file.

This PR just outputs warnings so I didn't change README.

Features must contain a change to an integration test file and the resulting snapshot.

No snapshot is needed because this PR is for CLI. And I'm waiting for cli-integ-tests to run.

Approved exemptions.

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Dec 23, 2024
@mrgrain
Copy link
Contributor

mrgrain commented Dec 23, 2024

PS @go-to-k I'll be off on xmas holidays, I've asked the team to do reviews. If there's no movement by the new year feel free to ping me on cdk.dev. 🎄

change order for calling methods

foreach to for

suggestStacks args to object
@go-to-k go-to-k marked this pull request as ready for review December 24, 2024 13:39
@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/32636/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.

@go-to-k
Copy link
Contributor Author

go-to-k commented Dec 24, 2024

@mrgrain

Thanks for your review! I have made all the suggested changes and added tests for the suggested stacks messages. I would love to see a review from you or the team.

This is a sample image:
cdk-destroy-warn

Happy Xmas!

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. distinguished-contributor [Pilot] contributed 50+ PRs to the CDK effort/medium Medium work item – several days of effort p2 pr/needs-cli-test-run This PR needs CLI tests run against it. 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/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
3 participants