mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
eventscripts: Add modulo (%) operator to ctdb_check_counter()
Also add it to the corresponding eventscript unit test infrastructure. Signed-off-by: Martin Schwenke <martin@meltin.net> (This used to be ctdb commit f4ef83a256f59eeb00b9a5bc10c28347e1ad1031)
This commit is contained in:
parent
bdbe37b24f
commit
0ca046577f
@ -1037,12 +1037,7 @@ drop_all_public_ips ()
|
||||
}
|
||||
|
||||
########################################################
|
||||
# some simple logic for counting events - per eventscript
|
||||
# usage: ctdb_counter_init
|
||||
# ctdb_counter_incr
|
||||
# ctdb_check_counter_limit <limit>
|
||||
# ctdb_check_counter_limit fails when count >= <limit>
|
||||
########################################################
|
||||
# Simple counters
|
||||
_ctdb_counter_common () {
|
||||
_service_name="${1:-${service_name:-${script_name}}}"
|
||||
_counter_file="$ctdb_fail_dir/$_service_name"
|
||||
@ -1068,7 +1063,17 @@ ctdb_check_counter () {
|
||||
|
||||
# unary counting!
|
||||
_size=$(stat -c "%s" "$_counter_file" 2>/dev/null || echo 0)
|
||||
if [ $_size $_op $_limit ] ; then
|
||||
_hit=false
|
||||
if [ "$_op" != "%" ] ; then
|
||||
if [ $_size $_op $_limit ] ; then
|
||||
_hit=true
|
||||
fi
|
||||
else
|
||||
if [ $(($_size $_op $_limit)) -eq 0 ] ; then
|
||||
_hit=true
|
||||
fi
|
||||
fi
|
||||
if $_hit ; then
|
||||
if [ "$_msg" = "error" ] ; then
|
||||
echo "ERROR: $_limit consecutive failures for $_service_name, marking node unhealthy"
|
||||
exit 1
|
||||
|
@ -675,7 +675,17 @@ rpc_set_service_failure_response ()
|
||||
\#*) continue ;;
|
||||
esac
|
||||
|
||||
if [ "$_numfails" "$_op" "$_li" ] ; then
|
||||
_hit=false
|
||||
if [ "$_op" != "%" ] ; then
|
||||
if [ $_numfails $_op $_li ] ; then
|
||||
_hit=true
|
||||
fi
|
||||
else
|
||||
if [ $(($_numfails $_op $_li)) -eq 0 ] ; then
|
||||
_hit=true
|
||||
fi
|
||||
fi
|
||||
if $_hit ; then
|
||||
_out=""
|
||||
_rc=0
|
||||
for _action in $_actions ; do
|
||||
|
Loading…
Reference in New Issue
Block a user