Add health check for OVN containers

This patch adds script for ovn_controller and ovn-dbs-bundle containers.
Health is check using verification of connection to OVN DB.

Change-Id: I9c8d0445b7f010838fe94dae2ae6fb86952fdeab
This commit is contained in:
Martin Mágr 2018-05-14 13:27:10 +02:00
parent cd1dd6aa83
commit b9905a052f
3 changed files with 42 additions and 2 deletions

View File

@ -14,7 +14,7 @@ healthcheck_port () {
process=$1
# ss truncate command name to 15 characters and this behaviour
# cannot be diabled
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
@ -29,7 +29,7 @@ healthcheck_listen () {
process=$1
# ss truncate command name to 15 characters and this behaviour
# cannot be diabled
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
@ -40,6 +40,19 @@ healthcheck_listen () {
ss -lnp | awk '{print $5,"-",$7}' | egrep ":($ports)" | grep "$process"
}
healthcheck_socket () {
process=$1
socket=$2
# lsof truncate command name to 15 characters and this behaviour
# cannot be disabled
if [ ${#process} -gt 15 ] ; then
process=${process:0:15}
fi
lsof -Fc -Ua $socket | grep "c$process"
}
get_config_val () {
crudini --get "$1" "$2" "$3" 2> /dev/null || echo "$4"
}

View File

@ -0,0 +1,14 @@
#!/bin/bash
. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh
process='ovn-controller'
args="${@:-6642}"
if healthcheck_port $process $args; then
exit 0
else
ports=${args// /,}
echo "There is no $process process connected to ovsdb ports $ports running in the container"
exit 1
fi

13
healthcheck/ovn-dbs Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
. ${HEALTHCHECK_SCRIPTS:-/usr/share/openstack-tripleo-common/healthcheck}/common.sh
process='ovn-northd'
sockets="${@:-/run/openvswitch/ovnnb_db.sock /run/openvswitch/ovnsb_db.sock}"
for sock in sockets; do
if ! healthcheck_socket $process $sock; then
echo "There is no $process process connected to socket $sock running in the container"
exit 1
fi
done