From 2c7acdbb6aa6273f6cab3d59a95f97353dfa4cac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E7=A5=96=E5=BB=BA?= Date: Sat, 16 Dec 2023 13:55:16 +0800 Subject: [PATCH] ovn-central: check raft inconsistency from nb/sb logs (#3532) Signed-off-by: zhangzujian --- dist/images/ovn-healthcheck.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dist/images/ovn-healthcheck.sh b/dist/images/ovn-healthcheck.sh index 5782b000969..86dc417218f 100755 --- a/dist/images/ovn-healthcheck.sh +++ b/dist/images/ovn-healthcheck.sh @@ -30,3 +30,19 @@ if echo ${sb_status} | grep "disconnected" && echo ${sb_role} | grep "candidate" echo "sb health check failed" exit 1 fi + +set +o pipefail + +# check nb/sb log file +function check_log_file() { + local log_file="/var/log/ovn/ovsdb-server-$1.log" + if [ -e $log_file ]; then + if grep -wE '(opened log file)|(does not match prerequisite)' $log_file 2>/dev/null | tail -n 1 | grep 'does not match prerequisite' ; then + echo "raft inconsistency in $1 db was detected, please check $log_file for more details." + return 1 + fi + fi +} + +check_log_file nb +check_log_file sb