-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
‼️ NOTICE: cdk deploy
fails when stacks share assets in v2.80.0
#25714
Comments
…en them share an asset (#25719) Fixes cdk deploy not completing for some apps by removing cycles from core's worker graph between asset publishing steps & stacks. These cycles may be introduced when there dependencies between stacks and these stacks share assets with the same contents. Additionally fixes a bug in the worker graph's error handling for cycles. Closes #25714 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
|
cdk deploy
does not run when dependant stacks share assetscdk deploy
does not run when dependant stacks share assets in v2.80.0
cdk deploy
does not run when dependant stacks share assets in v2.80.0cdk deploy
fails when stacks share assets in v2.80.0
only affects cli version 2.80.0 issue: aws/aws-cdk#25714
I get an issue in v1.81.0 (typescript), which I suspect is related to dependant stacks. In my environment we have many stacks which are dependant. This was making a linear dependency where each stack was dependant on an immediately prior stack. Found this easiest way to manage dependency order, where you individual devs may not have the context to determine this easily. This way we don't have to think about dependency order too hard, earlier means before anything later...easy. Mid way through our deployment we get an error: ❌ Deployment failed: Error: Unable to make progress anymore among: ... Where '...' is a printed list of every stack, simliar to: Downgrading to version 1.76.0 resolves the issue. Thanks a bunch. |
What is the issue?
In version 2.80.0 of the CDK cli, released May 19, 2023, a WorkGraph was introduced to handle tasks for
cdk deploy
. However, shared assets between CDK stacks resulted in a dependency cycle and the WorkGraph would be unable to determine what work to do next.A further issue was discovered later, which could result in a deployment to fail with
Error: Duplicate use of node id
.when Assets were shared between Stages.
What is the impact?
If a CDK app contains two stacks that have a dependency relationship between them, and both use the same asset, the
cdk deploy
command would exit early. The logs fromcdk deploy
abruptly end after the assets are published, without attempting the actual CloudFormation deploy. Notably the command exited with exit code0
and without any error message indicating the issue.Who is affected?
You are affected if you are using the CDK cli version >= 2.80.0,<2.83.1 and have shared assets between stacks or stages.
How do I resolve this?
Please upgrade to the latest version of the CDK cli.
Version 2.81.0 was released with a fix on May 25, 2023.
Version 2.83.1 was released with a fix on June 9, 2023.
Original issue below:
Describe the bug
Since upgrading from
v2.76.0
tov2.80.0
apps with dependant stacks that share assets fail to deploy. The logs fromcdk deploy
abruptly end after the assets are published, without attempting the actual CloudFormation deploy. Notably the command exited with exit code0
and without any error message indicating the issue.Visualising the deploy's
WorkGraph
, noticed that there was a cycle between the first stack and the shared asset.The stacks share the same asset because they both deploy a Lambda function bundled from the same directory.
This cycle is explained by the publish step depending on its parent stack's dependencies:
aws-cdk/packages/aws-cdk/lib/util/work-graph-builder.ts
Lines 73 to 80 in bbdb16a
Why does the deploy command exit abruptly without an error...
During my debugging I noticed that when an exception is thrown from inside the recursed graph traversal code it's possible for
active[x.type]--;
to be ran twice for the same node: once before callstart()
and again after an error is caught.aws-cdk/packages/aws-cdk/lib/util/work-graph.ts
Lines 168 to 178 in bbdb16a
This means that in the final
start()
calltotalActive() === -1
and therefore the final error check is skipped and the graph traversal exits without throwingaws-cdk/packages/aws-cdk/lib/util/work-graph.ts
Lines 154 to 162 in bbdb16a
Expected Behavior
Running
cdk deploy
should create/update CloudFormation stacks when there are changes.Current Behavior
The following is the output from a
cdk deploy
run that should have triggered cdk to create the app's stacks in CloudFormation.Reproduction Steps
See https://github.com/liamoneill/cdk-deploy-bug-reproduction
Possible Solution
active[x.type]--;
from being called twice for a single node.Additional Information/Context
No response
CDK CLI Version
2.80.0 (build bbdb16a)
Framework Version
No response
Node.js Version
v16.20.0
OS
OS X & Ubuntu
Language
Typescript
Language Version
TypeScript (5.0.4)
Other information
Output from adding in a
console.log(workGraph)
on this line https://github.com/aws/aws-cdk/blob/v2.80.0/packages/aws-cdk/lib/cdk-toolkit.ts#L364Thanks for the hard work on CDK! I'm a happy user.
The text was updated successfully, but these errors were encountered: