From 64b5b655cf1b593a6b2473fdc722f857cae481f5 Mon Sep 17 00:00:00 2001 From: randypanding Date: Sat, 22 Aug 2026 02:15:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(butler):=20heartbeat-watch=20=E9=98=88?= =?UTF-8?q?=E5=80=BC=E8=AF=BB=E5=8F=96=E8=B7=AF=E5=BE=84=E5=8B=98=E8=AF=AF?= =?UTF-8?q?=EF=BC=88thresholds=20=E5=B5=8C=E5=A5=97=E9=94=AE=20+=20?= =?UTF-8?q?=E6=98=BE=E5=BC=8F=20infra=20=E9=80=9A=E9=81=93=E9=98=B2=20bash?= =?UTF-8?q?=20-e=20=E5=90=9E=E9=94=99=EF=BC=89=EF=BC=88ADR-0074=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/butler-heartbeat-watch.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/butler-heartbeat-watch.yml b/.github/workflows/butler-heartbeat-watch.yml index de0eb28..8dedb16 100644 --- a/.github/workflows/butler-heartbeat-watch.yml +++ b/.github/workflows/butler-heartbeat-watch.yml @@ -45,7 +45,14 @@ jobs: echo "::error::缺 GOVERNANCE_TOKEN——陈旧度不可查,fail-closed 变红(不盲 trip)" >&2 exit 2 fi - STALE_H="${STALE_HOURS_OVERRIDE:-$(python3 -c 'import yaml; print(yaml.safe_load(open("governance/policy/butler.yaml", encoding="utf-8"))["deadman_stale_hours"])' | tr -d '\r')}" + # 阈值真源 = butler.yaml#thresholds.deadman_stale_hours(嵌套键——首版误读 + # 顶层键 KeyError;且 Actions 默认 bash -e 会令 $( ) 失败直灭脚本 exit 1, + # 现显式捕获走 infra 通道 exit 2) + STALE_H="${STALE_HOURS_OVERRIDE:-}" + if [[ -z "$STALE_H" ]]; then + STALE_H=$(python3 -c 'import yaml; print(yaml.safe_load(open("governance/policy/butler.yaml", encoding="utf-8"))["thresholds"]["deadman_stale_hours"])' | tr -d '\r') || { + echo "::error::butler.yaml thresholds.deadman_stale_hours 读取失败" >&2; exit 2; } + fi [[ "$STALE_H" =~ ^[0-9]+([.][0-9]+)?$ ]] || { echo "::error::deadman_stale_hours 非数值: $STALE_H" >&2; exit 2; } # 最近一次成功 heartbeat run 的完成时间(workflow 文件名路由;无成功 run = 视为最陈旧) LAST=$(gh api "repos/Cloudbird-Software/.github/actions/workflows/butler-heartbeat.yml/runs?status=success&per_page=1" \