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: --force flag does not applies to assets #197

Merged
merged 9 commits into from
Mar 7, 2025

Conversation

rix0rrr
Copy link
Contributor

@rix0rrr rix0rrr commented Mar 5, 2025

The cdk deploy --force flag is intended to disable all smartness around saving work. If set, it won't check whether assets already exist in the cloud, and remove the build and publishing steps from the work graph.

However, this by itself is not enough to make sure the asset truly gets published again, because the publish() action has its own version of short-circuiting again.

Rather than remove the short-circuiting behavior from cdk-assets, we add another { force } flag there as well, which gets its value from the CLI's --force flag.

This will make it possible to recover from corrupted assets which were accidentally published, as fixed in aws/aws-cdk#33692, by running rm -rf cdk.out && cdk deploy --force.

Fixes aws/aws-cdk#14474.


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

The `cdk deploy --force` flag is intended to disable all smartness
around saving work. If set, it won't check whether assets already exist
in the cloud, and remove the build and publishing steps from the work
graph.

However, this by itself is not enough to make sure the asset truly
gets published again, because the `publish()` action has its own
version of short-circuiting again.

Rather than remove the short-circuiting behavior from `cdk-assets`,
we add another `{ force }` flag there as well, which gets its value
from the CLI's `--force` flag.
@codecov-commenter
Copy link

codecov-commenter commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.22%. Comparing base (db6aa96) to head (6a98694).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #197      +/-   ##
==========================================
+ Coverage   85.10%   85.22%   +0.12%     
==========================================
  Files         208      208              
  Lines       35775    35786      +11     
  Branches     4631     4650      +19     
==========================================
+ Hits        30445    30500      +55     
+ Misses       5183     5131      -52     
- Partials      147      155       +8     
Flag Coverage Δ
suite.unit 85.22% <100.00%> (+0.12%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: github-actions <github-actions@github.com>
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.

Needs adding to toolkit-lib as well (as forcePublishAssets or something)

@rix0rrr
Copy link
Contributor Author

rix0rrr commented Mar 7, 2025

Needs adding to toolkit-lib as well (as forcePublishAssets or something)

Good catch.

Signed-off-by: github-actions <github-actions@github.com>
@mrgrain
Copy link
Contributor

mrgrain commented Mar 7, 2025

Applied pr/exempt-integ-test because test failure is unrelated.

@aws-cdk-automation aws-cdk-automation added this pull request to the merge queue Mar 7, 2025
Merged via the queue into main with commit da515f4 Mar 7, 2025
11 checks passed
@aws-cdk-automation aws-cdk-automation deleted the huijbers/force-applies-to-assets branch March 7, 2025 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 pr/exempt-integ-test Skips the integ test steps if set.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cdk-assets: Remove asset from staging bucket on failed deployment
6 participants