Skip to content

Commit

Permalink
fix: add optional role string
Browse files Browse the repository at this point in the history
  • Loading branch information
yabinji committed Mar 7, 2024
1 parent ec9fe18 commit 789c77b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions addons/mogdb/scripts/switchover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 789c77b

Please sign in to comment.