Evenscripts: improvements to ctdb_service_check_reconfigure().
authorMartin Schwenke <martin@meltin.net>
Thu, 13 Jan 2011 22:31:56 +0000 (09:31 +1100)
committerMartin Schwenke <martin@meltin.net>
Thu, 11 Aug 2011 00:46:57 +0000 (10:46 +1000)
* Make this function applicable to "ipreallocated" event too.

* Monitor event should not always succeed just because we reconfigure.

  If the service was unhealthy before the reconfigure and we end the
  reconfigure with "exit 0" then we can cause the node's health status
  to flip-flop.

  To avoid this we return the status of the service from the previous
  monitor event.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/functions

index e685c07ace7e6555933e084a63781d247d38f341..2668531ca834d305aa354a0fe293e6fca25fc9ae 100755 (executable)
@@ -689,11 +689,26 @@ service_reconfigure ()
 
 ctdb_service_check_reconfigure ()
 {
-    [ "$event_name" = "monitor" ] || return 0
+    # Only do this for certain events.
+    case "$event_name" in
+       monitor|ipreallocated) : ;;
+       *) return 0
+    esac
 
     if ctdb_service_needs_reconfigure "$@" ; then
        ctdb_service_reconfigure "$@"
-       exit 0
+
+       # Fall through to non-monitor events.
+       [ "$event_name" = "monitor" ] || return 0
+
+       # We don't want to proceed with the rest of the monitor event
+       # here, so we exit.  However, if we exit 0 then, if the
+       # service was previously broken, we might return a false
+       # positive.  So we simply retrieve the status of this script
+       # from the previous monitor loop and exit with that status.
+       ctdb scriptstatus | \
+           grep -q -E "^${script_name}[[:space:]]+Status:OK[[:space:]]"
+       exit $?
     fi
 }