Skip to content

Commit

Permalink
fix(cli): --exclusively leads to 0 stacks being selected
Browse files Browse the repository at this point in the history
The new concurrency logic introduced in #20345 was checking for all
dependencies to a stack to have been deployed previously for the stack
to be unblocked, but if not all stacks are selected, they will never
become unblocked.

Because there was no check on being "complete" at the end, this silently
leads to no stacks being deployed and the CLI no-opping.

Fix by only waiting for selected stacks among the dependencies, and
adding a safeguard at the end to make sure we deployed all stacks
successfully (or failed halfway through).
  • Loading branch information
rix0rrr committed Aug 18, 2022
1 parent ee1b66d commit 151d61e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/aws-cdk/lib/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const deployStacks = async (stacks: cxapi.CloudFormationStackArtifact[],
stack.dependencies
.map(({ id }) => id)
.filter((id) => !id.endsWith('.assets'))
.every((id) => deploymentStates[id] === 'completed');
.every((id) => !deploymentStates[id] || deploymentStates[id] === 'completed'); // Dependency not selected or already finished

const hasAnyStackFailed = (states: Record<string, DeploymentState>) => Object.values(states).includes('failed');

Expand Down Expand Up @@ -57,4 +57,10 @@ export const deployStacks = async (stacks: cxapi.CloudFormationStackArtifact[],
if (deploymentErrors.length) {
throw Error(`Stack Deployments Failed: ${deploymentErrors}`);
}

// We shouldn't be able to get here, but check it anyway
const neverUnblocked = Object.entries(deploymentStates).filter(([_, s]) => s === 'pending').map(([n, _]) => n);
if (neverUnblocked.length > 0) {
throw new Error(`The following stacks never became unblocked: ${neverUnblocked.join(', ')}`);
}
};

0 comments on commit 151d61e

Please sign in to comment.