Eventscripts - ensure the statd update-trigger file always exists.
authorMartin Schwenke <martin@meltin.net>
Tue, 16 Aug 2011 03:28:40 +0000 (13:28 +1000)
committerMartin Schwenke <martin@meltin.net>
Tue, 16 Aug 2011 03:28:40 +0000 (13:28 +1000)
See the comment in the code for details.

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

index 19a9ea81a1f2ebaf4acde07cffcbe2dfd07bfe65..87a91df5b5bb96eefd0637dc0339a39be4d333aa 100755 (executable)
@@ -9,7 +9,6 @@ service_start ()
     startstop_nfs stop
     startstop_nfs start
     set_proc "sys/net/ipv4/tcp_tw_recycle" 1
-    touch "$service_state_dir/update-trigger"
 }
 service_stop ()
 {
@@ -32,6 +31,14 @@ loadconfig
 
 ctdb_setup_service_state_dir
 
+statd_update_trigger="$service_state_dir/update-trigger"
+# We want this file to always exist.  The corner case is when
+# auto-start/stop is switched off, NFS is added as a managed service
+# some time after ctdbd is started and someone else starts the NFS
+# service for us.  In this case this file might not otherwise exist
+# when we get to a monitor event.
+touch "$statd_update_trigger"
+
 ctdb_start_stop_service
 
 is_ctdb_managed_service || exit 0
@@ -105,10 +112,10 @@ case "$1" in
 
        # once every 600 seconds, update the statd state database for which
        # clients need notifications
-       LAST_UPDATE=`stat --printf="%Y" "$service_state_dir/update-trigger"`
+       LAST_UPDATE=`stat --printf="%Y" "$statd_update_trigger"`
        CURRENT_TIME=`date +"%s"`
        [ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
-           touch "$service_state_dir/update-trigger"
+           touch "$statd_update_trigger"
            $CTDB_BASE/statd-callout updatelocal &
            $CTDB_BASE/statd-callout updateremote &
        }