fix(cluster): 兼容 CNPG 单实例预检

发布前先通过 merge patch 删除旧同步复制配置,期望清单不再写入 CRD 不接受的 null 值,确保 server-side dry-run 与正式 apply 使用相同的有效单实例状态。
This commit is contained in:
2026-08-04 23:29:48 +08:00
parent 8ef9de0b06
commit c79c2a7b44
3 changed files with 5 additions and 5 deletions
@@ -716,7 +716,7 @@ prepare_postgres_single_instance() {
local source_sha=$1
local current_instances current_primary primary_node synchronous_enabled
if ! grep -Eq '^ instances: 1$' "$DESIRED_STATE_DIR/database.yaml" ||
! grep -Eq '^ synchronous: null$' "$DESIRED_STATE_DIR/database.yaml"; then
grep -Eq '^[[:space:]]+synchronous:' "$DESIRED_STATE_DIR/database.yaml"; then
echo 'production PostgreSQL desired state must declare one instance with synchronous replication disabled' >&2
return 1
fi
@@ -117,9 +117,6 @@ spec:
cpu: "2"
memory: 3Gi
postgresql:
# Keep this explicit null so server-side apply atomically removes the old
# two-instance synchronous setting during preflight field management.
synchronous: null
parameters:
# A 16 MiB WAL segment every 60 seconds requires at least 2.24 Mbit/s
# of continuous cross-region throughput even while the database is idle.