[SCM] CTDB repository - branch master updated - ctdb-2.1-75-gdc4ca81

Amitay Isaacs amitay at samba.org
Sun Apr 21 23:42:48 MDT 2013


The branch, master has been updated
       via  dc4ca816630ed44b419108da53421331243fb8c7 (commit)
       via  bfed6a8d1771db3401d12b819204736c33acb312 (commit)
       via  5940a2494e9e43a83f2bca098bd04dfc1a8f2e93 (commit)
       via  0076cfc4666e5a96eb2c8affb59585b090840e00 (commit)
       via  700cf95a1f29b4b88460a00a55d57a9e397011e0 (commit)
       via  85efa446c7f5c5af1c3a960001aa777775ae562f (commit)
       via  d254d03f69cbdc3e473202b759af6e1392cbb59c (commit)
      from  e7a4b7e35a1e4b826846e2494a3803abb57065ee (commit)

http://gitweb.samba.org/?p=ctdb.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit dc4ca816630ed44b419108da53421331243fb8c7
Author: Amitay Isaacs <amitay at gmail.com>
Date:   Fri Apr 19 13:29:04 2013 +1000

    ctdbd: Set num_clients statistic from ctdb->num_clients
    
    This fixes the problem of "ctdb statisticsreset" clearing the number of
    clients even when there are active clients.
    
    Values returned in statistics for frozen, recovering, memory_used are based on
    the current state of CTDB and are not maintained as statistics.  This should
    include num_clients as well.
    
    Currently ctdb->num_clients is unused. So use that to track the number of
    clients and fill in statistics field only when requested.
    
    Signed-off-by: Amitay Isaacs <amitay at gmail.com>

commit bfed6a8d1771db3401d12b819204736c33acb312
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 22 13:52:04 2013 +1000

    ctdbd: Log PID file creation and removal at NOTICE level
    
    Unexpected removal of this file can have serious consequences, so it
    is best if this is logged at the default level.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 5940a2494e9e43a83f2bca098bd04dfc1a8f2e93
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 22 13:48:06 2013 +1000

    scripts: Ensure even external scripts get tagged in logs as "ctdbd"
    
    Our practice is to search logs for "ctdbd:".  We want to make sure we
    find everything.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 0076cfc4666e5a96eb2c8affb59585b090840e00
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 22 06:52:49 2013 +1000

    eventscripts: Ensure directories are created
    
    Previous commits stopped the top level of the script from creating
    certain directories but some functions assume that required
    directories exist.
    
    Create those directories instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 700cf95a1f29b4b88460a00a55d57a9e397011e0
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 17 13:26:04 2013 +1000

    scripts: Clean up update_tickles() and handling of associated directory
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 85efa446c7f5c5af1c3a960001aa777775ae562f
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Apr 17 13:12:32 2013 +1000

    scripts: Use $CTDB_SCRIPT_DEBUGLEVEL instead of something more complex
    
    The current logic is horrible and creates an unnecessary file.  Let's
    make the script debug level independent of ctddb's debug level.
    
    * Have debug() use $CTDB_SCRIPT_DEBUGLEVEL directly
    
    * Remove ctdb_set_current_debuglevel()
    
    * Remove the "getdebug" command from ctdb stub in eventscript unit
      tests
    
    * Update relevant eventscript unit tests to use
      $CTDB_SCRIPT_DEBUGLEVEL
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit d254d03f69cbdc3e473202b759af6e1392cbb59c
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Apr 19 13:10:27 2013 +1000

    scripts: Ensure service command is in $PATH in ctdb-crash-cleanup.sh
    
    Move the use of the service command below inclusion of functions file,
    which sets $PATH.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 config/ctdb-crash-cleanup.sh               |   14 ++++----
 config/ctdb.init                           |    2 +-
 config/events.d/00.ctdb                    |    5 ---
 config/functions                           |   55 +++++++---------------------
 server/ctdb_control.c                      |    3 +-
 server/ctdb_daemon.c                       |   10 +++---
 tests/eventscripts/50.samba.monitor.107.sh |    3 +-
 tests/eventscripts/50.samba.monitor.109.sh |    3 +-
 tests/eventscripts/50.samba.monitor.110.sh |    3 +-
 tests/eventscripts/stubs/ctdb              |   18 ---------
 10 files changed, 31 insertions(+), 85 deletions(-)


Changeset truncated at 500 lines:

diff --git a/config/ctdb-crash-cleanup.sh b/config/ctdb-crash-cleanup.sh
index 7796223..d26838e 100755
--- a/config/ctdb-crash-cleanup.sh
+++ b/config/ctdb-crash-cleanup.sh
@@ -4,16 +4,16 @@
 # all public ip addresses if CTDBD has crashed or stopped running.
 #
 
-# If ctdb is running, just exit
-if service ctdb status >/dev/null 2>&1 ; then
-    exit 0
-fi
-
 [ -n "$CTDB_BASE" ] || \
     export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
 
 . "$CTDB_BASE/functions"
 
+# If ctdb is running, just exit
+if service ctdb status >/dev/null 2>&1 ; then
+    exit 0
+fi
+
 loadconfig ctdb
 
 [ -n "$CTDB_PUBLIC_ADDRESSES" ] || \
@@ -22,8 +22,8 @@ loadconfig ctdb
 [ -f "$CTDB_PUBLIC_ADDRESSES" ] || \
     die "No public addresses file found. Can't clean up."
 
-drop_all_public_ips "ctdb-crash-cleanup"
+drop_all_public_ips "ctdb-crash-cleanup.sh"
 
 if [ -n "$CTDB_NATGW_PUBLIC_IP" ] ; then
-    drop_ip "$CTDB_NATGW_PUBLIC_IP" "ctdb-crash-cleanup"
+    drop_ip "$CTDB_NATGW_PUBLIC_IP" "ctdb-crash-cleanup.sh"
 fi
diff --git a/config/ctdb.init b/config/ctdb.init
index d92fef0..a76b763 100755
--- a/config/ctdb.init
+++ b/config/ctdb.init
@@ -249,7 +249,7 @@ start() {
 
     # make sure we drop any ips that might still be held if previous
     # instance of ctdb got killed with -9 or similar
-    drop_all_public_ips
+    drop_all_public_ips "ctdb.init"
 
     if select_tdb_checker ; then
 	check_persistent_databases || return $?
diff --git a/config/events.d/00.ctdb b/config/events.d/00.ctdb
index 0261353..c1ac11a 100755
--- a/config/events.d/00.ctdb
+++ b/config/events.d/00.ctdb
@@ -88,11 +88,6 @@ case "$1" in
 	update_config_from_tdb &
 	;;
     monitor)
-	# Inherit the debug level from ctdbd on each monitor run.  If
-	# there's a more urgent need then override CTDB_CURRENT_DEBUGLEVEL
-	# using a file in $CTDB_BASE/rc.local.d/.
-        ctdb_set_current_debuglevel create
-
 	# We should never enter swap, so SwapTotal == SwapFree.
 	[ "$CTDB_CHECK_SWAP_IS_NOT_USED" = "yes" ] && {
 	    if [ -n "`grep '^Swap\(Total\|Free\)' /proc/meminfo | uniq -s 10 -u`" ]; then
diff --git a/config/functions b/config/functions
index 8d186a0..b4450c3 100755
--- a/config/functions
+++ b/config/functions
@@ -42,39 +42,12 @@ loadconfig () {
 }
 
 ##############################################################
-# make sure CTDB_CURRENT_DEBUGLEVEL is set to the desired debug level
-# (integer)
-#
-# If it is already set then do nothing, since it might have been set
-# via a file in rc.local.d/.  If it is not set then set it by sourcing
-# /var/ctdb/eventscript_debuglevel. If this file does not exist then
-# create it using output from "ctdb getdebug".  If the option 1st arg
-# is "create" then don't source an existing file but create a new one
-# instead - this is useful for creating the file just once in each
-# event run in 00.ctdb.  If there's a problem getting the debug level
-# from ctdb then it is silently set to 0 - no use spamming logs if our
-# debug code is broken...
-ctdb_set_current_debuglevel ()
-{
-    [ -z "$CTDB_CURRENT_DEBUGLEVEL" ] || return 0
-
-    _f="$CTDB_VARDIR/eventscript_debuglevel"
-
-    if [ "$1" = "create" -o ! -r "$_f" ] ; then
-	_t=$(ctdb getdebug -Y 2>/dev/null)
-	# get last field of output
-	_t="${_t%:}"
-	_t="${_t##*:}"
-	# Defaults to 0
-	echo "export CTDB_CURRENT_DEBUGLEVEL=\"${_t:-0}\"" >"$_f"
-    fi
-
-    . "$_f"
-}
 
+# CTDB_SCRIPT_DEBUGLEVEL can be overwritten by setting it in a
+# configuration file.
 debug ()
 {
-    if [ $CTDB_CURRENT_DEBUGLEVEL -ge 4 ] ; then
+    if [ ${CTDB_SCRIPT_DEBUGLEVEL:-2} -ge 4 ] ; then
 	# If there are arguments then echo them.  Otherwise expect to
 	# use stdin, which allows us to pass lots of debug using a
 	# here document.
@@ -110,7 +83,7 @@ script_log ()
     esac
 
     if $_using_syslog ; then
-	logger -t "$_tag" "$*"
+	logger -t "ctdbd" "${_tag}: $*"
     else
 	{
 	    if [ -n "$*" ] ; then
@@ -128,7 +101,7 @@ background_with_logging ()
 {
     (
 	"$@" 2>&1 </dev/null |
-	script_log "ctdbd: ${script_name}&"
+	script_log "${script_name}&"
     )&
 
     return 0
@@ -609,6 +582,7 @@ kill_tcp_connections() {
 
     _killcount=0
     connfile="$CTDB_VARDIR/state/connections.$_IP"
+    mkdir -p "${connfile%/*}" # dirname
     netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
     netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile
 
@@ -659,6 +633,7 @@ kill_tcp_connections_local_only() {
 
     _killcount=0
     connfile="$CTDB_VARDIR/state/connections.$_IP"
+    mkdir -p "${connfile%/*}" # dirname
     netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
     netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile
 
@@ -701,6 +676,7 @@ tickle_tcp_connections() {
 
     _killcount=0
     connfile="$CTDB_VARDIR/state/connections.$_IP"
+    mkdir -p "${connfile%/*}" # dirname
     netstat -tn |egrep "^tcp.*[[:space:]]+$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' > $connfile
     netstat -tn |egrep "^tcp.*[[:space:]]+::ffff:$_IP:.*ESTABLISHED" | awk '{print $4" "$5}' >> $connfile
 
@@ -854,6 +830,7 @@ add_ip_to_iface()
     _maskbits=$3
 
     _lockfile="${CTDB_VARDIR}/state/interface_modify_${_iface}.flock"
+    mkdir -p "${_lockfile%/*}" # dirname
     [ -f "$_lockfile" ] || touch "$_lockfile"
 
     (
@@ -883,6 +860,7 @@ delete_ip_from_iface()
     _maskbits=$3
 
     _lockfile="${CTDB_VARDIR}/state/interface_modify_${_iface}.flock"
+    mkdir -p "${_lockfile%/*}" # dirname
     [ -f "$_lockfile" ] || touch "$_lockfile"
 
     (
@@ -1165,6 +1143,7 @@ ctdb_reconfigure_try_lock ()
     
     _ctdb_service_reconfigure_common "$@"
     _lock="${_d}/reconfigure_lock"
+    mkdir -p "${_lock%/*}" # dirname
     touch "$_lock"
 
     (
@@ -1444,15 +1423,12 @@ iptables()
 # tickle handling
 ########################################################
 
-# Temporary directory for tickles.
-tickledir="$CTDB_VARDIR/state/tickles"
-mkdir -p "$tickledir"
-
 update_tickles ()
 {
 	_port="$1"
 
-	mkdir -p "$tickledir" # Just in case
+	tickledir="$CTDB_VARDIR/state/tickles"
+	mkdir -p "$tickledir"
 
 	# Who am I?
 	_pnn=$(ctdb pnn) ; _pnn=${_pnn#PNN:}
@@ -1513,11 +1489,6 @@ update_tickles ()
 	done
 }
 
-# We'll call this here to ensure $CTDB_CURRENT_DEBUGLEVEL is set.
-# This gives us a chance to override the debug level using a file in
-# $CTDB_BASE/rc.local.d/.
-ctdb_set_current_debuglevel
-
 script_name="${0##*/}"       # basename
 service_name="$script_name"  # default is just the script name
 service_fail_limit=1
diff --git a/server/ctdb_control.c b/server/ctdb_control.c
index 99b3dc4..affb9dd 100644
--- a/server/ctdb_control.c
+++ b/server/ctdb_control.c
@@ -100,6 +100,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 		int i;
 		CHECK_CONTROL_DATA_SIZE(0);
 		ctdb->statistics.memory_used = talloc_total_size(NULL);
+		ctdb->statistics.num_clients = ctdb->num_clients;
 		ctdb->statistics.frozen = 0;
 		for (i=1; i<= NUM_DB_PRIORITIES; i++) {
 			if (ctdb->freeze_mode[i] == CTDB_FREEZE_FROZEN) {
@@ -204,7 +205,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
 
 	case CTDB_CONTROL_PING:
 		CHECK_CONTROL_DATA_SIZE(0);
-		return ctdb->statistics.num_clients;
+		return ctdb->num_clients;
 
 	case CTDB_CONTROL_SET_DB_READONLY: {
 		uint32_t db_id;
diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c
index 17902b3..2bd9346 100644
--- a/server/ctdb_daemon.c
+++ b/server/ctdb_daemon.c
@@ -245,7 +245,7 @@ static int ctdb_client_destructor(struct ctdb_client *client)
 
 	ctdb_takeover_client_destructor_hook(client);
 	ctdb_reqid_remove(client->ctdb, client->client_id);
-	CTDB_DECREMENT_STAT(client->ctdb, num_clients);
+	client->ctdb->num_clients--;
 
 	if (client->num_persistent_updates != 0) {
 		DEBUG(DEBUG_ERR,(__location__ " Client disconnecting with %u persistent updates in flight. Starting recovery\n", client->num_persistent_updates));
@@ -974,7 +974,7 @@ static void ctdb_accept_client(struct event_context *ev, struct fd_event *fde,
 
 	talloc_set_destructor(client, ctdb_client_destructor);
 	talloc_set_destructor(client_pid, ctdb_clientpid_destructor);
-	CTDB_INCREMENT_STAT(ctdb, num_clients);
+	ctdb->num_clients++;
 }
 
 
@@ -1109,8 +1109,8 @@ static void ctdb_remove_pidfile(void)
 {
 	if (ctdbd_pidfile != NULL && !ctdb_is_child_process()) {
 		if (unlink(ctdbd_pidfile) == 0) {
-			DEBUG(DEBUG_INFO, ("Removed PID file %s\n",
-					   ctdbd_pidfile));
+			DEBUG(DEBUG_NOTICE, ("Removed PID file %s\n",
+					     ctdbd_pidfile));
 		} else {
 			DEBUG(DEBUG_WARNING, ("Failed to Remove PID file %s\n",
 					      ctdbd_pidfile));
@@ -1132,7 +1132,7 @@ static void ctdb_create_pidfile(pid_t pid)
 
 		fprintf(fp, "%d\n", pid);
 		fclose(fp);
-		DEBUG(DEBUG_INFO, ("Created PID file %s\n", ctdbd_pidfile));
+		DEBUG(DEBUG_NOTICE, ("Created PID file %s\n", ctdbd_pidfile));
 		atexit(ctdb_remove_pidfile);
 	}
 }
diff --git a/tests/eventscripts/50.samba.monitor.107.sh b/tests/eventscripts/50.samba.monitor.107.sh
index 4c776ac..573ff80 100755
--- a/tests/eventscripts/50.samba.monitor.107.sh
+++ b/tests/eventscripts/50.samba.monitor.107.sh
@@ -4,8 +4,7 @@
 
 define_test "port 139 down, default tcp checker, debug"
 
-# This has to go before the setup, otherwise it will write a dud file.
-export CTDB_DEBUGLEVEL=4
+export CTDB_SCRIPT_DEBUGLEVEL=4
 
 setup_samba
 tcp_port_down 139
diff --git a/tests/eventscripts/50.samba.monitor.109.sh b/tests/eventscripts/50.samba.monitor.109.sh
index f90ba62..0104fd9 100755
--- a/tests/eventscripts/50.samba.monitor.109.sh
+++ b/tests/eventscripts/50.samba.monitor.109.sh
@@ -6,8 +6,7 @@ define_test "port 139 down, ctdb checktcpport not implemented, debug"
 
 ctdb_not_implemented "checktcpport"
 
-# This has to go before the setup, otherwise it will write a dud file.
-export CTDB_DEBUGLEVEL=4
+export CTDB_SCRIPT_DEBUGLEVEL=4
 
 setup_nmap_output_filter
 
diff --git a/tests/eventscripts/50.samba.monitor.110.sh b/tests/eventscripts/50.samba.monitor.110.sh
index 639cc51..4697e54 100755
--- a/tests/eventscripts/50.samba.monitor.110.sh
+++ b/tests/eventscripts/50.samba.monitor.110.sh
@@ -7,8 +7,7 @@ define_test "port 139 down, ctdb checktcpport/nmap not implemented, debug"
 ctdb_not_implemented "checktcpport"
 export FAKE_NMAP_NOT_FOUND="yes"
 
-# This has to go before the setup, otherwise it will write a dud file.
-export CTDB_DEBUGLEVEL=4
+export CTDB_SCRIPT_DEBUGLEVEL=4
 
 setup_nmap_output_filter
 
diff --git a/tests/eventscripts/stubs/ctdb b/tests/eventscripts/stubs/ctdb
index 3abdd16..34ac47e 100755
--- a/tests/eventscripts/stubs/ctdb
+++ b/tests/eventscripts/stubs/ctdb
@@ -274,24 +274,6 @@ case "$1" in
 		exit 1
 	esac
 	;;
-    getdebug)
-	case "${CTDB_DEBUGLEVEL:-0}" in
-	    -3) _t="EMERG"  ;;
-	    -2) _t="ALERT"  ;;
-	    -1) _t="CRIT"   ;;
-	    0) _t="ERR"     ;;
-	    1) _t="WARNING" ;;
-	    2) _t="NOTICE"  ;;
-	    3) _t="INFO"    ;;
-	    4) _t="DEBUG"   ;;
-	    *) _t="ERR"     ;;
-	esac
-
-	cat<<EOF
-:Name:Level:
-:${_t}:${CTDB_DEBUGLEVEL}:
-EOF
-	;;
     checktcpport)
 	for _i in $FAKE_TCP_LISTEN ; do
 	    if [ "$2" = "${_i##*:}" ] ; then


-- 
CTDB repository


More information about the samba-cvs mailing list