Skip to content

Commit

Permalink
fix: compatible with no norhtd svc
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Apr 15, 2021
1 parent 323cb12 commit f9c836b
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions dist/images/ovn-is-leader.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ fi
if [[ $sb_leader =~ "true" ]]
then
kubectl label --overwrite pod "$POD_NAME" -n "$POD_NAMESPACE" ovn-sb-leader=true
northd_leader=$(kubectl get ep -n kube-system ovn-northd -o jsonpath={.subsets\[0\].addresses\[0\].ip})
if [ "$northd_leader" == "" ]; then
# no available northd leader try to release the lock
set +e
if [[ "$ENABLE_SSL" == "false" ]]; then
ovsdb-client -v -t 1 steal tcp:127.0.0.1:6642 ovn_northd
else
ovsdb-client -v -t 1 -p /var/run/tls/key -c /var/run/tls/cert -C /var/run/tls/cacert steal ssl:127.0.0.1:6642 ovn_northd
set +e
northd_svc=$(kubectl get svc -n kube-system | grep ovn-northd)
if [ -z "$northd_svc" ]; then
echo "ovn-northd svc not exist"
else
northd_leader=$(kubectl get ep -n kube-system ovn-northd -o jsonpath={.subsets\[0\].addresses\[0\].ip})
if [ "$northd_leader" == "" ]; then
# no available northd leader try to release the lock
if [[ "$ENABLE_SSL" == "false" ]]; then
ovsdb-client -v -t 1 steal tcp:127.0.0.1:6642 ovn_northd
else
ovsdb-client -v -t 1 -p /var/run/tls/key -c /var/run/tls/cert -C /var/run/tls/cacert steal ssl:127.0.0.1:6642 ovn_northd
fi
fi
set -e
fi
set -e
else
kubectl label pod "$POD_NAME" -n "$POD_NAMESPACE" ovn-sb-leader-
fi

0 comments on commit f9c836b

Please sign in to comment.