diff options
-rwxr-xr-x | ctdb/config/functions | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/ctdb/config/functions b/ctdb/config/functions index 307b212f64..5ca7d8e693 100755 --- a/ctdb/config/functions +++ b/ctdb/config/functions @@ -1056,9 +1056,37 @@ ctdb_reconfigure_try_lock () ctdb_replay_monitor_status () { echo "Replaying previous status for this script due to reconfigure..." - ctdb scriptstatus -Y | \ - grep -q -F ":${script_name}:0:OK:" - exit $? + # Leading colon (':') is missing in some versions... + _out=$(ctdb scriptstatus -Y | grep -E "^:?monitor:${script_name}:") + # Output looks like this: + # :monitor:60.nfs:1:ERROR:1314764004.030861:1314764004.035514:foo bar: + # This is the cheapest way of getting fields in the middle. + set -- $(IFS=":" ; echo $_out) + _code="$3" + _status="$4" + # The error output field can include colons so we'll try to + # preserve them. The weak checking at the beginning tries to make + # this work for both broken (no leading ':') and fixed output. + _out="${_out%:}" + _err_out="${_out#*monitor:${script_name}:*:*:*:*:}" + case "$_status" in + OK) : ;; # Do nothing special. + TIMEDOUT) + # Recast this as an error, since we can't exit with the + # correct negative number. + _code=1 + _err_out="[Replay of TIMEDOUT scriptstatus - note incorrect return code.] ${_err_out}" + ;; + DISABLED) + # Recast this as an OK, since we can't exit with the + # correct negative number. + _code=0 + _err_out="[Replay of DISABLED scriptstatus - note incorrect return code.] ${_err_out}" + ;; + *) : ;; # Must be ERROR, do nothing special. + esac + echo "$_err_out" + exit $_code } ctdb_service_check_reconfigure () |