[SCM] CTDB repository - branch status-test updated - ctdb-1.0.104-9-gf1e350f

Ronnie Sahlberg sahlberg at samba.org
Wed Nov 18 23:23:19 MST 2009


The branch, status-test has been updated
       via  f1e350f9edb74cc44b6c5be4c062fd93e98ba8c4 (commit)
       via  ac655b0a65b32d809d47fec9821f7f31bb2fe2a7 (commit)
      from  364e70b763f0ccd7714d15723ad3ea4d7e2968a1 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=status-test


- Log -----------------------------------------------------------------
commit f1e350f9edb74cc44b6c5be4c062fd93e98ba8c4
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 19 16:48:19 2009 +1100

    Now vaguely tested initscript updates.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit ac655b0a65b32d809d47fec9821f7f31bb2fe2a7
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Nov 19 15:00:17 2009 +1100

    More untested eventscript factorisation.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

-----------------------------------------------------------------------

Summary of changes:
 config/ctdb.init              |    2 +-
 config/events.d/00.ctdb       |    8 +--
 config/events.d/01.reclock    |   60 +++++++-----------
 config/events.d/10.interface  |   11 +--
 config/events.d/11.natgw      |   15 ++---
 config/events.d/11.routing    |    6 +--
 config/events.d/20.multipathd |    9 +--
 config/events.d/31.clamd      |   41 +++++-------
 config/events.d/40.vsftpd     |    9 ++-
 config/events.d/41.httpd      |    8 ++-
 config/events.d/50.samba      |  141 +++++++++++++++++++----------------------
 config/events.d/60.nfs        |   85 +++++++++++++------------
 config/events.d/61.nfstickle  |   47 +++-----------
 config/events.d/70.iscsi      |   28 +++------
 config/events.d/91.lvs        |   16 +-----
 config/events.d/99.timeout    |   15 ++---
 config/functions              |   55 +++++++++-------
 config/statd-callout          |    4 +-
 18 files changed, 237 insertions(+), 323 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/ctdb.init b/config/ctdb.init
index 67747fd..4bd570d 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -250,7 +250,7 @@ status() {
 }
 
 
-case "$1" in
+case "$cmd" in
     start)
   	start
 	;;
diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb
index 90fd92f..f2ec5e8 100755
--- a/config/events.d/00.ctdb
+++ b/config/events.d/00.ctdb
@@ -10,13 +10,7 @@
 #     recovered  : called when ctdb has finished a recovery event
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-
-# ensure we have /bin and /usr/bin in the path
-PATH=/bin:/usr/bin:$PATH
-
-cmd="$1"
-shift
+loadconfig
 
 case $cmd in 
      startup)
diff --git a/config/events.d/01.reclock b/config/events.d/01.reclock
index 281c089..1b6cbf0 100755
--- a/config/events.d/01.reclock
+++ b/config/events.d/01.reclock
@@ -2,55 +2,43 @@
 # script to check accessibility to the reclock file on a node
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-
-cmd="$1"
-shift
-
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
-# Count the number of intervals that have passed when we have tried to
-# but failed to stat the reclock file.  after third failure the node
-# becomes unhealthy after the twentieth failure the node we shutdown
-# ctdbd
-RECLOCKCOUNT="fail-count"
+loadconfig
 
 case $cmd in 
-     startup)
-	ctdb_counter_init "$RECLOCKCOUNT"
+    startup)
+	ctdb_counter_init
 	;;
-
-      monitor)
-	ctdb_counter_incr "$RECLOCKCOUNT"
-	ctdb_counter_limit "$RECLOCKCOUNT" 200 && {
-		echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Shutting down."
-		df
-		sleep 1
-		ctdb shutdown
+    
+    monitor)
+	RECLOCKFILE=$(ctdb -Y getreclock)
+
+	ctdb_counter_incr
+	(ctdb_check_counter_limit 200 >/dev/null 2>&1) || {
+	    echo "Reclock file $RECLOCKFILE\" can not be accessed. Shutting down."
+	    df
+	    sleep 1
+	    ctdb shutdown
 	}
 
-	RECLOCKFILE=`ctdb -Y getreclock`
 	[ -z "$RECLOCKFILE" ] && {
-		# we are not using a reclock file
-		ctdb_counter_init "$RECLOCKCOUNT"
-		exit 0
+	    # we are not using a reclock file
+	    ctdb_counter_init
+	    exit 0
 	}
 
 	# try stat the reclock file as a background process
 	# so that we dont block in case the cluster filesystem is unavailable
 	(
-		stat $RECLOCKFILE && {
-			# we could stat the file, reset the counter
-			ctdb_counter_init "$RECLOCKCOUNT"
-		}
+	    stat $RECLOCKFILE && {
+		# we could stat the file, reset the counter
+		ctdb_counter_init
+	    }
 	) >/dev/null 2>/dev/null &
 
-
-	ctdb_counter_limit "$RECLOCKCOUNT" 3 && {
-		echo "Reclock file \"$RECLOCKFILE\" can not be accessed. Mark node UNHEALTHY."
-		df
-		exit 1;
-	}
+	ctdb_check_counter_limit 3 quiet
+	;;
+    status)
+	ctdb_checkstatus || exit $?
 	;;
 esac
 
diff --git a/config/events.d/10.interface b/config/events.d/10.interface
index 9a02b15..da6d903 100755
--- a/config/events.d/10.interface
+++ b/config/events.d/10.interface
@@ -6,10 +6,7 @@
 # public interface
 
 . $CTDB_BASE/functions
-loadconfig ctdb
-
-cmd="$1"
-shift
+loadconfig
 
 [ -z "$CTDB_PUBLIC_ADDRESSES" ] && {
 	CTDB_PUBLIC_ADDRESSES=$CTDB_BASE/public_addresses
@@ -177,10 +174,10 @@ case $cmd in
 	    esac
 	done
 	;;
-
+    status)
+	ctdb_checkstatus || exit $?
+	;;
 esac
 
 exit 0
 
-
-
diff --git a/config/events.d/11.natgw b/config/events.d/11.natgw
index 4ef651d..3a35094 100644
--- a/config/events.d/11.natgw
+++ b/config/events.d/11.natgw
@@ -6,15 +6,10 @@
 #
 
 . $CTDB_BASE/functions
-loadconfig ctdb
+loadconfig
 
 [ -z "$CTDB_NATGW_PUBLIC_IFACE" ] && exit 0
 
-cmd="$1"
-shift
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
-
 delete_all() {
 	remove_ip $CTDB_NATGW_PUBLIC_IP $CTDB_NATGW_PUBLIC_IFACE
 	remove_ip $CTDB_NATGW_PUBLIC_IP_HOST lo
@@ -28,7 +23,7 @@ delete_all() {
 }
 
 case $cmd in 
-     startup)
+    startup)
 	# do not respond to ARPs that are for ip addresses with scope 'host'
 	echo 3 > /proc/sys/net/ipv4/conf/all/arp_ignore
 	# do not send out arp requests from loopback addresses
@@ -37,13 +32,13 @@ case $cmd in
 	ctdb setnatgwstate on
 	;;
 
-     recovered|updatenatgw)
+    recovered|updatenatgw)
 	MYPNN=`ctdb pnn | cut -d: -f2`
 	NATGWMASTER=`ctdb natgwlist | head -1 | sed -e "s/ .*//"`
 	NATGWIP=`ctdb natgwlist | head -1 | sed -e "s/^[^ ]* *//"`
 
 	CTDB_NATGW_PUBLIC_IP_HOST=`echo $CTDB_NATGW_PUBLIC_IP | sed -e "s/\/.*/\/32/"`
-	if [ "$NATGWMASTER" = "-1" ]; then
+	if [ "$NATGWMASTER" == "-1" ]; then
 		echo "There is not NATGW master node"
 		exit 1
 	fi
@@ -71,7 +66,7 @@ case $cmd in
 	echo 1 > /proc/sys/net/ipv4/route/flush
 	;;
 
-     shutdown|removenatgw)
+    shutdown|removenatgw)
 	delete_all
 	;;
 
diff --git a/config/events.d/11.routing b/config/events.d/11.routing
index 0674193..cb34e41 100755
--- a/config/events.d/11.routing
+++ b/config/events.d/11.routing
@@ -13,16 +13,12 @@
 # bond1 10.3.3.0/24 10.0.0.1
 
 . $CTDB_BASE/functions
-loadconfig ctdb
+loadconfig
 
 [ -f $CTDB_BASE/static-routes ] || {
     exit 0
 }
 
-cmd="$1"
-shift
-PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
-
 case $cmd in 
      takeip|releaseip)
 	iface=$1
diff --git a/config/events.d/20.multipathd b/config/events.d/20.multipathd
index c740d69..cf722d8 100644
--- a/config/events.d/20.multipathd
+++ b/config/events.d/20.multipathd
@@ -6,14 +6,11 @@
 #   CTDB_MONITOR_MPDEVICES="device1 device2 ..."
 #
 
-PATH=/bin:/usr/bin:$PATH
-
 . $CTDB_BASE/functions
-loadconfig ctdb
-loadconfig multipathd
 
-cmd="$1"
-shift
+service_name="multipathd"
+
+loadconfig 
 
 [ -z "$CTDB_MONITOR_MPDEVICES" ] && {
 	exit 0
diff --git a/config/events.d/31.clamd b/config/events.d/31.clamd
index 842096a..a6515a9 100644
--- a/config/events.d/31.clamd
+++ b/config/events.d/31.clamd
@@ -2,52 +2,45 @@
 # event script to manage clamd in a cluster environment
 
 . $CTDB_BASE/functions
-loadconfig ctdb
 
 detect_init_style
 
 case $CTDB_INIT_STYLE in
 	redhat)
-		CTDB_SERVICE_CLAMD="clamd"
-		CTDB_CONFIG_CLAMD="clamd"
-		;;
-	suse)
-		CTDB_SERVICE_CLAMD="clamav"
-		CTDB_CONFIG_CLAMD="clamav"
-		;;
-	debian)
-		CTDB_SERVICE_CLAMD="clamav"
-		CTDB_CONFIG_CLAMD="clamav"
+		service_name="clamd"
+		service_config="clamd"
 		;;
 	*)
-		# should not happen.
-		# for now use red hat style as default
-		CTDB_SERVICE_CLAMD="clamd"
-		CTDB_CONFIG_CLAMD="clamd"
+		service_name="clamav"
+		service_config="clamav"
 		;;
 esac
 
-loadconfig "${CTDB_CONFIG_CLAMD}"
+service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start"
+service_stop="service $service_name stop"
+
+loadconfig
 
-[ "$CTDB_MANAGES_CLAMD" = "yes" ] || exit 0
+ctdb_start_stop_service
 
-cmd="$1"
-shift
+is_ctdb_managed_service || exit 0
 
 case $cmd in 
      startup)
-        service "${CTDB_SERVICE_CLAMD}" stop > /dev/null 2>&1
-        service "${CTDB_SERVICE_CLAMD}" start
+	ctdb_service_start
         ;;
 
      shutdown)
-        service "${CTDB_SERVICE_CLAMD}" stop
+        ctdb_service_stop
         ;;
 
      monitor)
-        ctdb_check_unix_socket "clamd" ${CTDB_CLAMD_SOCKET}
+        ctdb_check_unix_socket ${CTDB_CLAMD_SOCKET} || exit $?
         ;;
+
+    status)
+	ctdb_checkstatus || exit $?
+	;;
 esac
 
 exit 0
-
diff --git a/config/events.d/40.vsftpd b/config/events.d/40.vsftpd
index a87b07b..582604a 100755
--- a/config/events.d/40.vsftpd
+++ b/config/events.d/40.vsftpd
@@ -1,16 +1,16 @@
 #!/bin/sh
 # event strict to manage vsftpd in a cluster environment
 
+. $CTDB_BASE/functions
+
 service_name="vsftpd"
 # make sure the service is stopped first
-service_start="service vsftpd stop > /dev/null 2>&1 ; service vsftpd start"
-service_stop="service vsftpd stop"
+service_start="service $service_name stop > /dev/null 2>&1 ; service $service_name start"
+service_stop="service $service_name stop"
 service_reconfigure="service $service_name restart"
 service_fail_limit=2
 service_tcp_ports=21
 
-. $CTDB_BASE/functions
-
 loadconfig
 
 ctdb_start_stop_service
@@ -54,6 +54,7 @@ case $cmd in
 	    fi
 	fi	
 	;;
+
     status)
 	ctdb_checkstatus || exit $?
 	;;
diff --git a/config/events.d/41.httpd b/config/events.d/41.httpd
index 421f42a..7f9ee23 100755
--- a/config/events.d/41.httpd
+++ b/config/events.d/41.httpd
@@ -28,13 +28,15 @@ cleanup_httpd_semaphore_leak() {
 ##########
 
 service_start="cleanup_httpd_semaphore_leak; service $service_name start"
-service_stop="service $service_name stop; killall -q -9 $service_name"
+service_stop="service $service_name stop; killall -q -9 $service_name || true"
 service_reconfigure="service $service_name restart"
 
 loadconfig
 
 ctdb_start_stop_service
 
+is_ctdb_managed_service || exit 0
+
 case $cmd in
     startup)
 	ctdb_service_start
@@ -56,6 +58,10 @@ case $cmd in
 	    exit 1
 	fi
 	;;
+
+    status)
+	ctdb_checkstatus || exit $?
+	;;
 esac
 
 exit 0
diff --git a/config/events.d/50.samba b/config/events.d/50.samba
index bd4c5ff..e285347 100755
--- a/config/events.d/50.samba
+++ b/config/events.d/50.samba
@@ -1,13 +1,7 @@
 #!/bin/sh
 # ctdb event script for Samba
 
-PATH=/bin:/usr/bin:$PATH
-
-service_name="samba"
-
 . $CTDB_BASE/functions
-loadconfig ctdb
-loadconfig samba
 
 detect_init_style
 
@@ -22,11 +16,6 @@ case $CTDB_INIT_STYLE in
 		CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
 		CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
 		;;
-	redhat)
-		CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
-		CTDB_SERVICE_NMB=${CTDB_SERVICE_NMB:-""}
-		CTDB_SERVICE_WINBIND=${CTDB_SERVICE_WINBIND:-winbind}
-		;;
 	*)
 		# should not happen, but for now use redhat style as default:
 		CTDB_SERVICE_SMB=${CTDB_SERVICE_SMB:-smb}
@@ -35,11 +24,69 @@ case $CTDB_INIT_STYLE in
 		;;
 esac
 
-cmd="$1"
-shift
+service_name="samba"
+service_start="start_samba"
+service_stop="stop_samba"
+
+loadconfig
 
 [ "$CTDB_MANAGES_SAMBA" = "yes" ] || [ "$CTDB_MANAGES_WINBIND" = "yes" ] || exit 0
 
+start_samba() {
+	# create the state directory for samba
+	/bin/mkdir -p $CTDB_BASE/state/samba
+
+	# make sure samba is not already started
+	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+		service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
+		service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
+		killall -0 -q smbd && {
+		    sleep 1
+		    # make absolutely sure samba is dead
+		    killall -q -9 smbd
+		}
+
+		killall -0 -q nmbd && {
+		    sleep 1
+		    # make absolutely sure samba is dead
+		    killall -q -9 nmbd
+		}
+	}
+
+	# restart the winbind service
+	check_ctdb_manages_winbind
+	[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
+		service "$CTDB_SERVICE_WINBIND" stop > /dev/null 2>&1
+		killall -0 -q winbindd && {
+		    sleep 1
+          	    # make absolutely sure winbindd is dead
+		    killall -q -9 winbindd
+		}
+		service "$CTDB_SERVICE_WINBIND" start
+	}
+
+	# start Samba service. Start it reniced, as under very heavy load 
+	# the number of smbd processes will mean that it leaves few cycles for
+	# anything else
+	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+		nice_service "$CTDB_SERVICE_NMB" start
+		nice_service "$CTDB_SERVICE_SMB" start
+	}
+}
+
+stop_samba() {
+	# shutdown Samba when ctdb goes down
+	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
+		service "$CTDB_SERVICE_SMB" stop
+		service "$CTDB_SERVICE_NMB" stop
+	}
+
+	# stop the winbind service
+	check_ctdb_manages_winbind
+	[ "$CTDB_MANAGES_WINBIND" = "yes" ] && {
+		service "$CTDB_SERVICE_WINBIND" stop
+	}
+}
 
 # set default samba cleanup period - in minutes
 [ -z "$SAMBA_CLEANUP_PERIOD" ] && {
@@ -143,72 +190,11 @@ periodic_cleanup() {
 
 case $cmd in 
      startup)
-	# create the state directory for samba
-	/bin/mkdir -p $CTDB_BASE/state/samba
-
-	# make sure samba is not already started
-	[ "$CTDB_MANAGES_SAMBA" = "yes" ] && {
-		service "$CTDB_SERVICE_SMB" stop > /dev/null 2>&1
-		service "$CTDB_SERVICE_NMB" stop > /dev/null 2>&1
-		killall -0 -q smbd && {
-		    sleep 1
-		    # make absolutely sure samba is dead


-- 
CTDB repository


More information about the samba-cvs mailing list