Eventscripts: 10.interfaces clean-ups - push logic into monitor_interfaces().
authorMartin Schwenke <martin@meltin.net>
Tue, 28 Jun 2011 06:27:01 +0000 (16:27 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 12 Aug 2011 05:00:03 +0000 (15:00 +1000)
The logic in the monitor event itself is very complex.  Nearly all of
it can go away by adding a single check of
$CTDB_PARTIALLY_ONLINE_INTERFACES to the return logic of
monitor_interfaces() and reversing the sense of the corresponding
check.

Signed-off-by: Martin Schwenke <martin@meltin.net>
config/events.d/10.interface

index 207a9d38ca3420d35ccda83ffcbaab1fa75bc228..f998a6492bb28321cba557644af458bb7a5a4a39 100755 (executable)
@@ -111,7 +111,9 @@ monitor_interfaces()
 
        $fail || return 0
 
-       $up_interfaces_found && return 2
+       $up_interfaces_found && \
+           [ "$CTDB_PARTIALLY_ONLINE_INTERFACES" = "yes" ] && \
+           return 0
 
        return 1
 }
@@ -270,21 +272,7 @@ case "$1" in
        ;;
 
      monitor)
-       monitor_interfaces
-       ret=$?
-
-       test x"$ret" = x"2" && {
-               test x"$CTDB_PARTIALLY_ONLINE_INTERFACES" != x"yes" && {
-                       exit 1;
-               }
-               # as long as we have one interface available don't become
-               # unhealthy
-               ret=0
-       }
-
-       test x"$ret" != x"0" && {
-               exit 1;
-       }
+       monitor_interfaces || exit 1
        ;;
     *)
        ctdb_standard_event_handler "$@"