From 85b8dd6690350bbe25e2c9ebb427d736c0d2af8b 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 cc6efc88b12..cf9b7f57182 100755 --- a/dist/images/ovs-healthcheck.sh +++ b/dist/images/ovs-healthcheck.sh @@ -40,3 +40,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