fix(release): 兼容首次创建容量控制器
旧生产集群没有 capacity-controller,部署前精确快照此前对缺失 Deployment 直接报错,导致目标状态尚未应用就阻断发布。 快照现在允许目标 Deployment 不存在;失败恢复时,快照中原本不存在的资源会被删除,从而同时支持首次创建和精确回退。 验证:bash -n、ShellCheck、人工发布脚本测试、线上缺失控制器只读快照演练。
This commit is contained in:
@@ -291,6 +291,7 @@ snapshot_application_deployments() {
|
|||||||
easyai-api-ningbo easyai-api-hongkong \
|
easyai-api-ningbo easyai-api-hongkong \
|
||||||
easyai-worker-ningbo easyai-worker-hongkong \
|
easyai-worker-ningbo easyai-worker-hongkong \
|
||||||
easyai-capacity-controller easyai-web-ningbo easyai-web-hongkong \
|
easyai-capacity-controller easyai-web-ningbo easyai-web-hongkong \
|
||||||
|
--ignore-not-found=true \
|
||||||
-o json |
|
-o json |
|
||||||
jq '
|
jq '
|
||||||
del(.metadata)
|
del(.metadata)
|
||||||
@@ -310,14 +311,21 @@ snapshot_application_deployments() {
|
|||||||
|
|
||||||
restore_application_deployments() {
|
restore_application_deployments() {
|
||||||
local snapshot=$1
|
local snapshot=$1
|
||||||
|
local deployment
|
||||||
[[ -s $snapshot ]] || return 1
|
[[ -s $snapshot ]] || return 1
|
||||||
"${kubectl[@]}" apply -f "$snapshot" >/dev/null
|
"${kubectl[@]}" apply -f "$snapshot" >/dev/null
|
||||||
for deployment in \
|
for deployment in \
|
||||||
easyai-api-ningbo easyai-api-hongkong \
|
easyai-api-ningbo easyai-api-hongkong \
|
||||||
easyai-worker-ningbo easyai-worker-hongkong \
|
easyai-worker-ningbo easyai-worker-hongkong \
|
||||||
easyai-capacity-controller easyai-web-ningbo easyai-web-hongkong; do
|
easyai-capacity-controller easyai-web-ningbo easyai-web-hongkong; do
|
||||||
"${kubectl[@]}" rollout status "deployment/$deployment" \
|
if jq -e --arg name "$deployment" \
|
||||||
-n "$NAMESPACE" --timeout=300s || true
|
'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
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user