
This works is based on http://github.com/openstack-fuel-ccp-rabbitmq and it mostly adjusts this solution to a helm based deployment.
64 lines
1.9 KiB
Smarty
64 lines
1.9 KiB
Smarty
#!/usr/bin/env bash
|
|
# This is taken from https://github.com/openstack/fuel-ccp-rabbitmq/blob/master/service/files/rabbitmq-liveness.sh.j2
|
|
set -eu
|
|
set -o pipefail
|
|
exec 1>/proc/1/fd/2 2>/proc/1/fd/2
|
|
|
|
source $(readlink -f $(dirname $0))/rabbitmq-check-helpers.sh
|
|
set-log-prefix "liveness:$$"
|
|
log-it "Starting liveness probe at $(date +'%Y-%m-%d %H:%M:%S')"
|
|
|
|
main() {
|
|
local marker_state
|
|
marker_state="$(marker-state)"
|
|
case $marker_state in
|
|
missing)
|
|
log-it "Startup marker missing, probably probe was executed too early"
|
|
return 0
|
|
;;
|
|
fresh) # node has recently started - it can still be booting
|
|
if ! ping-node; then
|
|
log-it "Fresh node, erlang VM hasn't started yet - giving it another chance"
|
|
# Erlang VM hasn't started yet
|
|
return 0
|
|
fi
|
|
if is-node-booting; then
|
|
log-it "Node is still booting, giving it some time to finish"
|
|
return 0
|
|
fi
|
|
if ! is-node-healthy; then
|
|
log-it "Node is unhealthy"
|
|
return 1
|
|
fi
|
|
if ! is-node-properly-clustered; then
|
|
log-it "Found clustering inconsistency, giving up"
|
|
return 1
|
|
fi
|
|
return 0
|
|
;;
|
|
stale) # node has started long ago - it shoud be either ready or dead
|
|
if ! is-node-healthy; then
|
|
log-it "Long-running node become unhealthy"
|
|
return 1
|
|
fi
|
|
if ! is-node-properly-clustered; then
|
|
echo "Long-running node became inconsistent with the rest of the cluster"
|
|
return 1
|
|
fi
|
|
return 0
|
|
;;
|
|
*)
|
|
log-it "Unexpected marker-state '$marker-state'"
|
|
return 1
|
|
;;
|
|
esac
|
|
}
|
|
|
|
if main; then
|
|
rc=0
|
|
else
|
|
rc=$?
|
|
fi
|
|
log-it "Ready to return $rc"
|
|
exit $rc
|