From 220faec1766fbc2d237fea4785e9aff5e6c97bd1 Mon Sep 17 00:00:00 2001 From: xingran Date: Fri, 11 Aug 2023 17:56:44 +0800 Subject: [PATCH] fix: backward compatibility upgrade postgresql from v0.5.1 to v0.6.0 (#4731) --- deploy/postgresql/templates/scripts.yaml | 25 ++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/deploy/postgresql/templates/scripts.yaml b/deploy/postgresql/templates/scripts.yaml index 77de0c41e55..3df22e3cb48 100644 --- a/deploy/postgresql/templates/scripts.yaml +++ b/deploy/postgresql/templates/scripts.yaml @@ -96,17 +96,22 @@ data: fi } - # Waiting for primary pod information from the DownwardAPI annotation to be available, with a maximum of 5 attempts - attempt=1 - max_attempts=10 - while [ $attempt -le $max_attempts ] && [ -z "$(cat /kb-podinfo/primary-pod)" ]; do - sleep 3 - attempt=$((attempt + 1)) - done + if [ -f /kb-podinfo/primary-pod ]; then + # Waiting for primary pod information from the DownwardAPI annotation to be available, with a maximum of 5 attempts + attempt=1 + max_attempts=10 + while [ $attempt -le $max_attempts ] && [ -z "$(cat /kb-podinfo/primary-pod)" ]; do + sleep 3 + attempt=$((attempt + 1)) + done + + primary=$(cat /kb-podinfo/primary-pod) + echo "DownwardAPI get primary=$primary" >> /home/postgres/pgdata/.kb_set_up.log + echo "KB_POD_NAME=$KB_POD_NAME" >> /home/postgres/pgdata/.kb_set_up.log + else + echo "DownwardAPI get /kb-podinfo/primary-pod is empty" >> /home/postgres/pgdata/.kb_set_up.log + fi - primary=$(cat /kb-podinfo/primary-pod) - echo "DownwardAPI get primary=$primary" >> /home/postgres/pgdata/.kb_set_up.log - echo "KB_POD_NAME=$KB_POD_NAME" >> /home/postgres/pgdata/.kb_set_up.log if [ ! -z "$primary" ] && [ "$primary" != "$KB_POD_NAME" ]; then primary_fqdn="$primary.$KB_CLUSTER_NAME-$KB_COMP_NAME-headless.$KB_NAMESPACE.svc" echo "primary_fqdn=$primary_fqdn" >> /home/postgres/pgdata/.kb_set_up.log