From 760966660e2644eeec30e243eeb7756e205276fd Mon Sep 17 00:00:00 2001 From: Lemon-miaow Date: Sat, 26 Sep 2026 19:17:49 +0800 Subject: [PATCH] =?UTF-8?q?fix(bootstrap):=20=E5=85=A8=E6=96=B0=E4=B8=BB?= =?UTF-8?q?=E6=9C=BA=E6=B2=A1=E6=9C=89=20PostgreSQL=20=E9=9B=86=E7=BE=A4?= =?UTF-8?q?=E6=97=B6=E4=B8=8D=E5=86=8D=E5=9B=A0=20pipefail=20=E4=B8=AD?= =?UTF-8?q?=E6=AD=A2=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/bootstrap.sh | 3 ++- deploy/bootstrap_test.sh | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/deploy/bootstrap.sh b/deploy/bootstrap.sh index 2e4c4bb..1f7ce48 100644 --- a/deploy/bootstrap.sh +++ b/deploy/bootstrap.sh @@ -3721,7 +3721,8 @@ check_postgres_major() { want="$(postgres_image_major)" [ -n "$want" ] || die "cannot read a PostgreSQL major version from ${POSTGRES_IMAGE}" [ -f "${PG_DATA_DIR}/${want}/docker/PG_VERSION" ] && return 0 - found="$(cat "$PG_DATA_DIR"/*/docker/PG_VERSION 2>/dev/null | tr -d '[:space:]')" + # A fresh host has no cluster: the glob matches nothing and cat fails the pipeline. + found="$(cat "$PG_DATA_DIR"/*/docker/PG_VERSION 2>/dev/null | tr -d '[:space:]')" || true [ -z "$found" ] && return 0 die "this release runs PostgreSQL ${want}, but ${PG_DATA_DIR} holds a PostgreSQL ${found} cluster. PostgreSQL ${want} would start an empty cluster beside it. A new major version is a dump diff --git a/deploy/bootstrap_test.sh b/deploy/bootstrap_test.sh index a72b3ce..ecf461a 100644 --- a/deploy/bootstrap_test.sh +++ b/deploy/bootstrap_test.sh @@ -2921,7 +2921,9 @@ run_major() { # data-dir die() { printf "DIE: %s\n" "$*"; exit 1; } '"$(bsfn postgres_image_major)"' '"$(bsfn check_postgres_major)"' - check_postgres_major && echo STARTS' 2>&1 + # A plain statement, as main calls it: on the left of && errexit is off inside the function. + check_postgres_major + echo STARTS' 2>&1 } pmdir="$(mktemp -d)" expect "an empty data directory starts" "STARTS" "$(run_major "$pmdir")" @@ -3155,7 +3157,8 @@ run_compare() { # host pod [pod-exit] host_pg_counts() { printf "%s\n" "$H"; } pod_pg_counts() { printf "%s\n" "$P"; return "$PX"; } '"$(bsfn compare_pg_counts)"' - compare_pg_counts && echo SAME' 2>&1 + compare_pg_counts + echo SAME' 2>&1 } counts="audit_logs 505${nl}servers 3${nl}users 17" expect "the same rows in every table pass" "SAME" "$(run_compare "$counts" "$counts")"