fix(cluster): 兼容 CNPG 单实例预检
发布前先通过 merge patch 删除旧同步复制配置,期望清单不再写入 CRD 不接受的 null 值,确保 server-side dry-run 与正式 apply 使用相同的有效单实例状态。
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -316,7 +316,10 @@ if grep -Fq 'archive_timeout: 60s' "$root/deploy/kubernetes/production/database.
|
||||
fi
|
||||
grep -Fq ' instances: 1' "$root/deploy/kubernetes/production/database.yaml"
|
||||
grep -Fq ' easyai.io/site: ningbo' "$root/deploy/kubernetes/production/database.yaml"
|
||||
grep -Fq ' synchronous: null' "$root/deploy/kubernetes/production/database.yaml"
|
||||
if grep -Eq '^[[:space:]]+synchronous:' "$root/deploy/kubernetes/production/database.yaml"; then
|
||||
echo 'production single-instance PostgreSQL must not declare synchronous replication' >&2
|
||||
exit 1
|
||||
fi
|
||||
grep -Fq 'wal_sender_timeout: 30s' "$root/deploy/kubernetes/production/database.yaml"
|
||||
grep -Fq 'wal_receiver_timeout: 30s' "$root/deploy/kubernetes/production/database.yaml"
|
||||
bash -n "$root/scripts/cluster/configure-control-plane-io.sh"
|
||||
|
||||
Reference in New Issue
Block a user