From 789c77b6a65eb6cba900a39baf000444fd8245c2 Mon Sep 17 00:00:00 2001 From: "yabin.ji" Date: Thu, 7 Mar 2024 10:37:59 +0800 Subject: [PATCH] fix: add optional role string --- addons/mogdb/scripts/switchover.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mogdb/scripts/switchover.sh b/addons/mogdb/scripts/switchover.sh index 41f8a9109..b7ce64471 100644 --- a/addons/mogdb/scripts/switchover.sh +++ b/addons/mogdb/scripts/switchover.sh @@ -5,7 +5,7 @@ set -x # do switchover echo "INFO: doing switchover.." echo "INFO: candidate: ${candidate}" -kubectl exec -it mc-mogdb-1 -c mogdb -- gosu omm gs_ctl switchover +kubectl exec -it ${candidate} -c mogdb -- gosu omm gs_ctl switchover # check if switchover successfully. echo "INFO: start to check if switchover successfully, timeout is 60s" @@ -15,7 +15,7 @@ while true; do if [ ! -z ${candidate} ]; then # if candidate specified, only check it role=$(kubectl get pod ${candidate} -ojson | jq -r '.metadata.labels["kubeblocks.io/role"]') - if [ "$role" == "primary" ] || [ "$role" == "leader" ] || [ "$role" == "master" ]; then + if [ "$role" == "Primary" ] || [ "$role" == "primary" ] || [ "$role" == "leader" ] || [ "$role" == "master" ]; then echo "INFO: switchover successfully, ${candidate} is ${role}" exit 0 fi @@ -25,7 +25,7 @@ while true; do for podName in ${pods}; do if [ "${podName}" != "${primary}" ];then role=$(kubectl get pod ${podName} -ojson | jq -r '.metadata.labels["kubeblocks.io/role"]') - if [ "$role" == "primary" ] || [ "$role" == "leader" ] || [ "$role" == "master" ]; then + if [ "$role" == "Primary" ] || [ "$role" == "primary" ] || [ "$role" == "leader" ] || [ "$role" == "master" ]; then echo "INFO: switchover successfully, ${podName} is ${role}" exit 0 fi