From f4adb5685c198b6f95a42e2a2b34517c39a887d3 Mon Sep 17 00:00:00 2001 From: admin Date: Mon, 14 Sep 2026 12:05:37 +0800 Subject: [PATCH] =?UTF-8?q?deploy(agent):=20verify=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E3=80=8C=E8=B4=A6=E5=8F=B7=E7=BA=A7=E8=B4=9F=E8=BD=BD=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E3=80=8D=E6=8D=A2=E6=96=B0=E8=AF=81=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.0.14 起单 auth 的旧记录也会合成 accounts[],投影带 load; 旧镜像 items 里没有 accounts 键 —— 可干净区分新旧镜像。 三态判定(ok / noupstream / old)避免线上无上游时假失败。 已用 6 组输入干跑验证(含 data 为数组的兼容分支)。 --- deploy/agent.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/deploy/agent.sh b/deploy/agent.sh index 2e13ad8..0208686 100755 --- a/deploy/agent.sh +++ b/deploy/agent.sh @@ -167,6 +167,28 @@ print(len(d.get("labels") or []))' 2>/dev/null || echo '')" echo " ✗ 趋势接口异常(labels=${labels:-空})—— 镜像可能没真正换新"; rc=1 fi + # 4) 上游账号级负载(1.0.14 新增):投影里出现 accounts[].load = 新代码在跑。 + # 1.0.14 起**单 auth 的旧记录也会被合成为一条 account**,所以只要有任一上游记录, + # 新镜像必定返回该字段;旧镜像返回的 items 里根本没有 accounts 键 —— 新旧可分。 + # 只验「字段在不在」不验数值(线上未必有流量)。三态避免「空库」时假失败。 + local acct + acct="$(live_curl -b "$jar" "https://$LIVE_HOST:$LIVE_PORT/api/admin/upstreams" \ + | "$PY" -c 'import json,sys +d = json.load(sys.stdin).get("data") or {} +items = d.get("items") or [] if isinstance(d, dict) else (d if isinstance(d, list) else []) +if not items: + print("noupstream"); sys.exit(0) +for u in items: + for a in (u.get("accounts") or []): + if isinstance(a.get("load"), dict) and "requests" in a["load"]: + print("ok"); sys.exit(0) +print("old")' 2>/dev/null || echo '')" + case "$acct" in + ok) echo " ✓ 上游带账号级负载字段(accounts[].load)" ;; + noupstream) echo " · 线上没有任何上游,跳过账号负载证据(不判失败)" ;; + *) echo " ✗ 上游接口缺 accounts[].load —— 镜像可能没真正换新"; rc=1 ;; + esac + rm -f "$jar" if [ "$rc" = "0" ]; then echo "✔ 正式环境验收通过"; else echo "✗ 正式环境验收未通过"; fi return $rc