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