From 993fb7d8beba5cf081dd4bdbe6592204250f7384 Mon Sep 17 00:00:00 2001 From: wangbo Date: Fri, 31 Jul 2026 23:38:55 +0800 Subject: [PATCH] =?UTF-8?q?fix(release):=20=E5=85=BC=E5=AE=B9=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E5=88=9B=E5=BB=BA=E5=AE=B9=E9=87=8F=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 旧生产集群没有 capacity-controller,部署前精确快照此前对缺失 Deployment 直接报错,导致目标状态尚未应用就阻断发布。 快照现在允许目标 Deployment 不存在;失败恢复时,快照中原本不存在的资源会被删除,从而同时支持首次创建和精确回退。 验证:bash -n、ShellCheck、人工发布脚本测试、线上缺失控制器只读快照演练。 --- deploy/kubernetes/easyai-ai-gateway-cluster-release | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/deploy/kubernetes/easyai-ai-gateway-cluster-release b/deploy/kubernetes/easyai-ai-gateway-cluster-release index b9a6d1c..77dc623 100755 --- a/deploy/kubernetes/easyai-ai-gateway-cluster-release +++ b/deploy/kubernetes/easyai-ai-gateway-cluster-release @@ -291,6 +291,7 @@ snapshot_application_deployments() { easyai-api-ningbo easyai-api-hongkong \ easyai-worker-ningbo easyai-worker-hongkong \ easyai-capacity-controller easyai-web-ningbo easyai-web-hongkong \ + --ignore-not-found=true \ -o json | jq ' del(.metadata) @@ -310,14 +311,21 @@ snapshot_application_deployments() { restore_application_deployments() { local snapshot=$1 + local deployment [[ -s $snapshot ]] || return 1 "${kubectl[@]}" apply -f "$snapshot" >/dev/null for deployment in \ easyai-api-ningbo easyai-api-hongkong \ easyai-worker-ningbo easyai-worker-hongkong \ easyai-capacity-controller easyai-web-ningbo easyai-web-hongkong; do - "${kubectl[@]}" rollout status "deployment/$deployment" \ - -n "$NAMESPACE" --timeout=300s || true + if jq -e --arg name "$deployment" \ + 'any(.items[]; .metadata.name == $name)' "$snapshot" >/dev/null; then + "${kubectl[@]}" rollout status "deployment/$deployment" \ + -n "$NAMESPACE" --timeout=300s || true + else + "${kubectl[@]}" delete deployment "$deployment" -n "$NAMESPACE" \ + --ignore-not-found=true --wait=true >/dev/null || true + fi done }