From e1f7d72c15b61b083590672745c79b5d8a2d903a Mon Sep 17 00:00:00 2001 From: hzma Date: Thu, 27 Oct 2022 10:14:18 +0800 Subject: [PATCH] add check of write to ovn sb db for ovn-controller (#1989) --- dist/images/ovs-healthcheck.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dist/images/ovs-healthcheck.sh b/dist/images/ovs-healthcheck.sh index 9b0f7aad1ea..7b00540b89c 100755 --- a/dist/images/ovs-healthcheck.sh +++ b/dist/images/ovs-healthcheck.sh @@ -34,3 +34,19 @@ alias ovn-ctl='/usr/share/ovn/scripts/ovn-ctl' ovs-ctl status ovn-ctl status_controller + +# check if ovn-controller can write to ovn sb db +file="/var/log/ovn/ovn-controller.log" +if [ -e $file ] +then + result=$(tail -6 $file) + if [[ "$result" =~ "clustered database server has stale data" ]] + then + echo "check write to ovn sb db, clustered database server has stale data, run sb-cluster-state-reset command to restore" + pid=$(cat /var/run/ovn/ovn-controller.pid) + ovs-appctl -t /var/run/ovn/ovn-controller.$pid.ctl sb-cluster-state-reset + echo "finish exec cmd sb-cluster-state-reset" + else + echo "check write to ovn sb db success" + fi +fi