Skip to content

fix(deploy): 让 cdk bootstrap 步骤可见、失败可诊断 - #104

Merged
ddpie merged 1 commit into
mainfrom
fix/bootstrap-visibility
Jul 8, 2026
Merged

fix(deploy): 让 cdk bootstrap 步骤可见、失败可诊断#104
ddpie merged 1 commit into
mainfrom
fix/bootstrap-visibility

Conversation

@ddpie

@ddpie ddpie commented Jul 8, 2026

Copy link
Copy Markdown
Owner

背景

执行 cdk bootstrap 这一步的可观测性太差:脚本用 npm install --silent + 无额外输出的 npx cdk bootstrap,一旦遇到下面任一情况,屏幕上什么都看不到,看着就像死住了——

  • npm 源慢,卡在装 CDK 依赖;
  • 网络到不了 AWS(国内环境常见),cdk 还会先联网拉一次 notices 公告,能挂好几分钟;
  • 其实没卡,只是在等 CloudFormation 把 CDKToolkit 栈建出来(正常 1–2 分钟)。

改动

scripts/deploy.shensure_bootstrap

  • 去掉 npm install--silent,装依赖进度可见,源慢/卡住一眼能看出来。
  • bootstrap 加 CDK_DISABLE_NOTICES=1,跳过 cdk 的联网公告检查,避免在访问不了 notices endpoint 的网络上干等。
  • 开跑前打印一行「正在 Bootstrap……通常需 1–2 分钟,请耐心等待」,把正常等待和真卡死区分开。
  • 失败时给一条可操作的报错,直接指向三个排查点:网络、aws sts get-caller-identity、CloudFormation 控制台里 CDKToolkit 栈的失败原因。

config/i18n.json:新增 bootstrap_running / bootstrap_failed 两条串,中英各一份。

CDK 快照:config/i18n.json 被 OAuth Lambda 直接 import,新增 shell 段字符串改变了打包 asset 哈希,故按惯例 npm run test:update 刷新快照。

验证

  • ./scripts/test.sh 离线套件全绿(lint / typecheck / vitest / shell)。
  • 本地用脚本同款 i18n 加载逻辑实测两条新串在中英文下渲染正确、%s 正常替换。
  • 真实 cdk bootstrap 需连 AWS,未在本地执行;逻辑改动不影响已 bootstrap 区域(脚本仍先探测 CDKToolkit 栈状态,已存在则跳过)。

Background

The Run cdk bootstrap step has poor visibility: it runs npm install --silent plus a npx cdk bootstrap with no extra output, so whenever any of the following happens the screen shows nothing and it looks hung —

  • a slow npm registry stalling the CDK dependency install;
  • no network path to AWS (common in mainland China) — cdk also does a networked notices check first, which can hang for minutes;
  • nothing actually stuck, just waiting on CloudFormation to create the CDKToolkit stack (a normal 1–2 min).

Changes

scripts/deploy.sh (ensure_bootstrap)

  • Drop --silent from npm install so install progress is visible.
  • Add CDK_DISABLE_NOTICES=1 to bootstrap, skipping cdk's networked notices check so it can't hang on restricted networks.
  • Print a "Bootstrapping… usually 1–2 min, please wait" line up front to distinguish a normal wait from a real hang.
  • On failure, emit an actionable error pointing at network, aws sts get-caller-identity, and the CDKToolkit stack's failure reason in the CloudFormation console.

config/i18n.json: add bootstrap_running / bootstrap_failed, zh + en.

CDK snapshot: config/i18n.json is imported directly by the OAuth Lambda, so the new shell strings changed its bundle asset hash — refreshed via npm run test:update per convention.

Verification

  • ./scripts/test.sh offline suite green (lint / typecheck / vitest / shell).
  • Locally rendered both new strings via the script's own i18n loader — correct in zh/en, %s substitutes fine.
  • Real cdk bootstrap needs AWS and wasn't run locally; the change is a no-op for already-bootstrapped regions (the script still probes CDKToolkit first and skips if present).

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds localized "bootstrap running" and "bootstrap failed" messages for Chinese and English locales in config/i18n.json, and updates scripts/deploy.sh's ensure_bootstrap() function to display these messages, run npm install with visible output, disable CDK notices, and handle bootstrap failures with explicit error exit.

Changes

Bootstrap Messaging and Error Handling

Layer / File(s) Summary
Localized bootstrap messages
config/i18n.json
Adds bootstrap_running and bootstrap_failed strings to shell.zh and shell.en locales, including guidance on checking AWS access, credentials, and CDKToolkit stack failures.
Bootstrap execution and failure handling
scripts/deploy.sh
Updates ensure_bootstrap() to print the new running message, run npm install without silent suppression, set CDK_DISABLE_NOTICES=1, and wrap the bootstrap command so failures print the localized failure message and exit with status 1.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: making cdk bootstrap visible and easier to diagnose on failure.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bootstrap-visibility

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

bootstrap 之前用 npm install --silent + 无输出的 npx cdk bootstrap,一旦
卡住(npm 源慢、网络到不了 AWS、或只是在等 CloudFormation 建栈)完全看不到
进度,看着像死住。

- 去掉 npm install 的 --silent,装依赖进度可见
- bootstrap 加 CDK_DISABLE_NOTICES=1,避免在访问不了 AWS notices endpoint
  的网络(国内常见)上挂几分钟
- 开跑前打印"正在 Bootstrap……通常需 1-2 分钟"提示,区分正常等待与卡死
- 失败时给可操作报错,指向网络 / get-caller-identity / CloudFormation 栈

i18n.json 被 OAuth Lambda 直接 import,新增的 shell 段字符串改变了打包
asset 哈希,故一并刷新 CDK 快照。
@ddpie
ddpie force-pushed the fix/bootstrap-visibility branch from 05981a6 to eb1430a Compare July 8, 2026 10:16
@ddpie
ddpie merged commit 0ed6bab into main Jul 8, 2026
9 checks passed
@ddpie
ddpie deleted the fix/bootstrap-visibility branch July 8, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant