-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli):
cdk deploy
hangs when stack deployment fails (#6433)
* fix(cli): `cdk deploy` hangs when stack deployment fails Previously, when a stack would fail deployment we were using process.exit() which exited as quickly as possible even if async operations were pending. We rectified that by setting process.exitCode = 1 to allow all output to be flushed before a graceful exit. However, since we were not handling deployment errors, the Stack Activity Monitor was still polling every 5 seconds as the monitor is never explicitly halted. With this change, when a stack deployment fails, we halt the monitor before throwing the error. This ensures that there are no open handles when we call process.exitCode = 1 * move stoppage of the monitor into a finally block to clean the code up * remove unnecessary comment * added integ test * oops - added new file * use '?' instead of 'if' * added removalPolicy to destroy bucket when orphaned + use a unique name * verify the deployment actually failed * use an empty policy to fail deployment * remove unused s3 Co-authored-by: Eli Polonsky <Eli.polonsky@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
- Loading branch information
1 parent
71de590
commit 4b11d99
Showing
3 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
packages/aws-cdk/test/integ/cli/test-cdk-failed-deploy-doesnt-hang.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
scriptdir=$(cd $(dirname $0) && pwd) | ||
source ${scriptdir}/common.bash | ||
# ---------------------------------------------------------- | ||
|
||
setup | ||
|
||
set +e | ||
# this will hang if we introduce https://github.com/aws/aws-cdk/issues/6403 again. | ||
cdk deploy -v ${STACK_NAME_PREFIX}-failed | ||
deploy_status=$? | ||
set -e | ||
|
||
# destroy | ||
cdk destroy -f ${STACK_NAME_PREFIX}-failed | ||
|
||
if [ "${deploy_status}" -eq 0 ]; then | ||
fail "stack deployment should have failed" | ||
fi | ||
|
||
echo "✅ success" |