ctdb-scripts: Drop ctdb_check_service_reconfigure
authorAmitay Isaacs <amitay@gmail.com>
Wed, 14 Dec 2016 04:09:24 +0000 (15:09 +1100)
committerAmitay Isaacs <amitay@samba.org>
Fri, 16 Dec 2016 07:42:32 +0000 (08:42 +0100)
This gets rid of implicit check if a service needs to configured.  As a
side effect, we also get rid of the monitor "replay" which was
introduced to avoid a collision between a script executed via event and
manually.  Event scripts are not expected to be run by hand.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/config/functions

index 727bd8661b8f392fa5a21d823b367ee9fc180547..7e37bbb445f4175a249ac6f286725c4792158e44 100755 (executable)
@@ -853,139 +853,6 @@ service_reconfigure ()
     :
 }
 
-ctdb_reconfigure_take_lock ()
-{
-       _ctdb_service_reconfigure_common
-       _lock="${_d}/reconfigure_lock"
-       mkdir -p "${_lock%/*}" # dirname
-       touch "$_lock"
-
-       (
-               flock 9
-               # This is overkill but will work if we need to extend
-               # this to allow certain events to run multiple times
-               # in parallel (e.g. takeip) and write multiple PIDs to
-               # the file.
-               {
-                       read _locker_event
-                       if [ -n "$_locker_event" ] ; then
-                               while read _pid ; do
-                                       if [ -n "$_pid" -a "$_pid" != $$ ] && \
-                                          kill -0 "$_pid" 2>/dev/null ; then
-                                               exit 1
-                                       fi
-                               done
-                       fi
-               } <"$_lock"
-
-               printf "%s\n%s\n" "$event_name" $$ >"$_lock"
-               exit 0
-    ) 9>"${_lock}.flock"
-}
-
-ctdb_reconfigure_release_lock ()
-{
-    _ctdb_service_reconfigure_common
-    _lock="${_d}/reconfigure_lock"
-
-    rm -f "$_lock"
-}
-
-ctdb_replay_monitor_status ()
-{
-    echo "Replaying previous status for this script due to reconfigure..."
-    # Leading separator ('|') is missing in some versions...
-    _out=$($CTDB scriptstatus -X | 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.
-    # Intentional word splitting here
-    # shellcheck disable=SC2046,2086
-    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
-    if [ -n "$_err_out" ] ; then
-       echo "$_err_out"
-    fi
-    exit $_code
-}
-
-ctdb_service_check_reconfigure ()
-{
-    assert_service_name
-
-    # We only care about some events in this function.  For others we
-    # return now.
-    case "$event_name" in
-       monitor|ipreallocated|reconfigure) : ;;
-       *) return 0 ;;
-    esac
-
-    if ctdb_reconfigure_take_lock ; then
-       # No events covered by this function are running, so proceed
-       # with gay abandon.
-       case "$event_name" in
-           reconfigure)
-               (ctdb_service_reconfigure)
-               exit $?
-               ;;
-           ipreallocated)
-               if ctdb_service_needs_reconfigure ; then
-                   ctdb_service_reconfigure
-               fi
-               ;;
-       esac
-
-       ctdb_reconfigure_release_lock
-    else
-       # Somebody else is running an event we don't want to collide
-       # with.  We proceed with caution.
-       case "$event_name" in
-           reconfigure)
-               # Tell whoever called us to retry.
-               exit 2
-               ;;
-           ipreallocated)
-               # Defer any scheduled reconfigure and just run the
-               # rest of the ipreallocated event, as per the
-               # eventscript.  There's an assumption here that the
-               # event doesn't depend on any scheduled reconfigure.
-               # This is true in the current code.
-               return 0
-               ;;
-           monitor)
-               # There is most likely a reconfigure in progress so
-               # the service is possibly unstable.  As above, we
-               # defer any scheduled reconfigured.  We also replay
-               # the previous monitor status since that's the best
-               # information we have.
-               ctdb_replay_monitor_status
-               ;;
-       esac
-    fi
-}
-
 ##################################################################
 # Does CTDB manage this service? - and associated auto-start/stop