fix(acceptance): 修复本地数据库身份标记
通过 psql 标准输入执行变量替换,并校验本地集群标识格式,确保安全标记在导入生产脱敏快照前可靠写入,避免验收编排因 -c 参数不展开变量而退出。\n\n验证:bash -n;ShellCheck;本地 CNPG 双实例实际写入与查询标记通过。
This commit is contained in:
@@ -263,13 +263,14 @@ mark_local_database() {
|
||||
local primary
|
||||
primary=$(kubectl --context "$context" -n "$namespace" get cluster easyai-postgres \
|
||||
-o 'jsonpath={.status.currentPrimary}')
|
||||
kubectl --context "$context" -n "$namespace" exec "$primary" -c postgres -- \
|
||||
psql -X -v ON_ERROR_STOP=1 -U postgres -d easyai_ai_gateway \
|
||||
-v cluster_id="$LOCAL_CLUSTER_ID" -c \
|
||||
"INSERT INTO system_settings(setting_key,value)
|
||||
VALUES('acceptance_local_cluster_id',jsonb_build_object('clusterId', :'cluster_id'))
|
||||
ON CONFLICT(setting_key) DO UPDATE SET value=excluded.value,updated_at=now();" \
|
||||
>/dev/null
|
||||
[[ $LOCAL_CLUSTER_ID =~ ^easyai-local-[0-9a-f]{24}$ ]]
|
||||
printf '%s\n' \
|
||||
"INSERT INTO system_settings(setting_key,value)
|
||||
VALUES('acceptance_local_cluster_id',jsonb_build_object('clusterId', :'cluster_id'))
|
||||
ON CONFLICT(setting_key) DO UPDATE SET value=excluded.value,updated_at=now();" |
|
||||
kubectl --context "$context" -n "$namespace" exec -i "$primary" -c postgres -- \
|
||||
psql -X -v ON_ERROR_STOP=1 -U postgres -d easyai_ai_gateway \
|
||||
-v cluster_id="$LOCAL_CLUSTER_ID" >/dev/null
|
||||
}
|
||||
|
||||
import_snapshot() {
|
||||
|
||||
Reference in New Issue
Block a user