From 6df23c2b668a3b39338eabdc1da84985c0b47b88 Mon Sep 17 00:00:00 2001 From: zhangzujian Date: Wed, 21 Sep 2022 10:04:13 +0800 Subject: [PATCH] add network partition check in ovn probes --- dist/images/ovn-healthcheck.sh | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/dist/images/ovn-healthcheck.sh b/dist/images/ovn-healthcheck.sh index 91f4d2074a4..326536b0287 100755 --- a/dist/images/ovn-healthcheck.sh +++ b/dist/images/ovn-healthcheck.sh @@ -8,5 +8,23 @@ ovn-ctl status_northd ovn-ctl status_ovnnb | grep -q '^running' ovn-ctl status_ovnsb | grep -q '^running' -ovn-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound | grep Status | grep -v "failed" -ovn-appctl -t /var/run/ovn/ovnsb_db.ctl cluster/status OVN_Southbound | grep Status | grep -v "failed" +nb_status=$(ovn-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound | grep Status) +sb_status=$(ovn-appctl -t /var/run/ovn/ovnsb_db.ctl cluster/status OVN_Southbound | grep Status) +nb_role=$(ovn-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/status OVN_Northbound | grep Role) +sb_role=$(ovn-appctl -t /var/run/ovn/ovnsb_db.ctl cluster/status OVN_Southbound | grep Role) + +if ! echo ${nb_status} | grep -v "failed"; then + echo "nb health check failed" +fi +if ! echo ${sb_status} | grep -v "failed"; then + echo "sb health check failed" +fi + +if echo ${nb_status} | grep "disconnected" && echo ${nb_role} | grep "candidate"; then + echo "nb health check failed" + exit 1 +fi +if echo ${sb_status} | grep "disconnected" && echo ${sb_role} | grep "candidate"; then + echo "sb health check failed" + exit 1 +fi