[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Wed Feb 18 00:04:02 MST 2015


The branch, master has been updated
       via  dc32f11 ctdb-scripts: Improve messages about invalid tunables during "setup"
       via  c3706e7 ctdb-tool: Print a warning when setting an obsolete tunable variable
       via  54f0c39 ctdb-client: Return a value of 1 when setting obsolete tunable variable
       via  2c7c353 ctdb-tests: New tests for 00.ctdb "setup" event - set tunables from config
       via  39686f4 ctdb-scripts: Fix tunable setup code by making it shell-agnostic
       via  664d62b ctdb: Change default debug level to NOTICE (2)
      from  4bbfc54 lib: texpect. Fix the build on Solaris.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit dc32f11b871a7d4e8ea6fd1d01491d89103decf7
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Feb 14 12:53:08 2015 +1100

    ctdb-scripts: Improve messages about invalid tunables during "setup"
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    Autobuild-User(master): Amitay Isaacs <amitay at samba.org>
    Autobuild-Date(master): Wed Feb 18 08:03:33 CET 2015 on sn-devel-104

commit c3706e7fb07bcb35f7d894c4e8e0c12b4a62d0db
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 9 10:33:35 2015 +1100

    ctdb-tool: Print a warning when setting an obsolete tunable variable
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 54f0c39e5a33871847aa9fe2c070c7f638f54cc4
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 9 10:32:47 2015 +1100

    ctdb-client: Return a value of 1 when setting obsolete tunable variable
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 2c7c35377e5452e37925b970253b70875a8d7470
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Feb 15 14:39:51 2015 +1100

    ctdb-tests: New tests for 00.ctdb "setup" event - set tunables from config
    
    Unit test infrastructure tweaks to support.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 39686f45056d942de5ebe3263a533a99ca17c79e
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 16 14:04:09 2015 +1100

    ctdb-scripts: Fix tunable setup code by making it shell-agnostic
    
    All tunables set in configuration are currently set to 0 on system
    where /bin/sh is dash (and perhaps other non-bash shells).  dash puts
    single quotes around all values in the output of the "set" builtin
    command, whereas bash only puts them around values when something
    needs to be quoted.  Tunables always have a simple integer value so
    dash will quote them and bash won't.  The setup code currently passes
    the raw value, including any quotes to "ctdb setvar ...".  This
    command does no error checking on the input, so "'1'" is converted to
    0.
    
    Change the code so that the value is determined from the shell
    variable and is independent of the "set" output.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 664d62b61108657d3011cf0bcbe260533c97676f
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Feb 9 12:04:41 2015 +1100

    ctdb: Change default debug level to NOTICE (2)
    
    This was true for the daemon until commit
    b4589b954e1090a934fafd3f8e3c2cf1ed785c61.
    
    Defaulting to ERR in the ctdb CLI tool encourages logging notices at
    ERR level, so default to NOTICE instead.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/client/ctdb_client.c                          |  4 ++--
 ctdb/common/cmdline.c                              |  6 ++---
 ctdb/config/ctdb.sysconfig                         |  4 ++--
 ctdb/config/events.d/00.ctdb                       | 20 +++++++++++------
 ctdb/doc/ctdb.1.xml                                |  2 +-
 ctdb/doc/ctdbd.1.xml                               |  4 +---
 ctdb/doc/ctdbd.conf.5.xml                          |  2 +-
 ctdb/server/ctdb_tunables.c                        |  1 +
 ...terface.monitor.002.sh => 00.ctdb.setup.001.sh} |  2 +-
 ctdb/tests/eventscripts/00.ctdb.setup.002.sh       | 19 ++++++++++++++++
 ctdb/tests/eventscripts/00.ctdb.setup.003.sh       | 21 +++++++++++++++++
 ctdb/tests/eventscripts/00.ctdb.setup.004.sh       | 20 +++++++++++++++++
 ctdb/tests/eventscripts/etc/sysconfig/ctdb         |  4 ++++
 ctdb/tests/eventscripts/scripts/local.sh           | 11 +++++++++
 ctdb/tests/eventscripts/stubs/ctdb                 | 26 ++++++++++++++++++++++
 ctdb/tools/ctdb.c                                  |  5 +++++
 16 files changed, 131 insertions(+), 20 deletions(-)
 copy ctdb/tests/eventscripts/{10.interface.monitor.002.sh => 00.ctdb.setup.001.sh} (64%)
 create mode 100755 ctdb/tests/eventscripts/00.ctdb.setup.002.sh
 create mode 100755 ctdb/tests/eventscripts/00.ctdb.setup.003.sh
 create mode 100755 ctdb/tests/eventscripts/00.ctdb.setup.004.sh


Changeset truncated at 500 lines:

diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c
index 533f36f..fc34b8a 100644
--- a/ctdb/client/ctdb_client.c
+++ b/ctdb/client/ctdb_client.c
@@ -2735,12 +2735,12 @@ int ctdb_ctrl_set_tunable(struct ctdb_context *ctdb,
 	ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_SET_TUNABLE, 0, data, NULL,
 			   NULL, &res, &timeout, NULL);
 	talloc_free(data.dptr);
-	if (ret != 0 || res != 0) {
+	if ((ret != 0) || (res == -1)) {
 		DEBUG(DEBUG_ERR,(__location__ " ctdb_control for set_tunable failed\n"));
 		return -1;
 	}
 
-	return 0;
+	return res;
 }
 
 /*
diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c
index 4ed3fae..7fcb91f 100644
--- a/ctdb/common/cmdline.c
+++ b/ctdb/common/cmdline.c
@@ -37,7 +37,7 @@ static struct {
 	const char *events;
 } ctdb_cmdline = {
 	.torture = 0,
-	.debuglevel = "ERR",
+	.debuglevel = "NOTICE",
 };
 
 enum {OPT_EVENTSYSTEM=1};
@@ -97,7 +97,7 @@ struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 
 	/* Set the debug level */
 	if (!parse_debug(ctdb_cmdline.debuglevel, &DEBUGLEVEL)) {
-		DEBUGLEVEL = DEBUG_ERR;
+		DEBUGLEVEL = DEBUG_NOTICE;
 	}
 
 	/* set up the tree to store server ids */
@@ -146,7 +146,7 @@ struct ctdb_context *ctdb_cmdline_client(struct tevent_context *ev,
 
 	/* Set the debug level */
 	if (!parse_debug(ctdb_cmdline.debuglevel, &DEBUGLEVEL)) {
-		DEBUGLEVEL = DEBUG_ERR;
+		DEBUGLEVEL = DEBUG_NOTICE;
 	}
 
 	ret = ctdb_socket_connect(ctdb);
diff --git a/ctdb/config/ctdb.sysconfig b/ctdb/config/ctdb.sysconfig
index b44e478..9541d50 100644
--- a/ctdb/config/ctdb.sysconfig
+++ b/ctdb/config/ctdb.sysconfig
@@ -25,8 +25,8 @@ CTDB_PUBLIC_ADDRESSES=/etc/ctdb/public_addresses
 # Default is to use the log file below instead of syslog.
 # CTDB_LOGGING=file:/var/log/log.ctdb
 
-# Default log level is ERR.  NOTICE is a little more verbose.
-CTDB_DEBUGLEVEL=NOTICE
+# Default log level is NOTICE.  Want less logging?
+# CTDB_DEBUGLEVEL=ERR
 
 # Set some CTDB tunable variables during CTDB startup?
 # CTDB_SET_TraverseTimeout=60
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index a0f4102..ec18175 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -119,14 +119,19 @@ update_config_from_tdb() {
     fi
 }
 
-set_ctdb_variables () {
+set_ctdb_variables ()
+{
     # set any tunables from the config file
-    set | grep ^CTDB_SET_ | cut -d_ -f3- | 
+    set | sed -n '/^CTDB_SET_/s/=.*//p' |
     while read v; do
-	varname=`echo $v | cut -d= -f1`
-	value=`echo $v | cut -d= -f2`
-	ctdb setvar $varname $value || return 1
-	echo "Set $varname to $value"
+	varname="${v#CTDB_SET_}"
+	value=$(eval echo "\$$v")
+	if ctdb setvar $varname $value ; then
+	    echo "Set $varname to $value"
+	else
+	    echo "Invalid configuration: CTDB_SET_${varname}=${value}"
+	    return 1
+	fi
     done
 }
 
@@ -198,7 +203,8 @@ case "$1" in
 
     setup)
 	# Set any tunables from the config file
-	set_ctdb_variables || die "Failed to set CTDB tunables"
+	set_ctdb_variables || \
+	    die "Aborting setup due to invalid configuration - fix typos, remove unknown tunables"
 	;;
 
     startup)
diff --git a/ctdb/doc/ctdb.1.xml b/ctdb/doc/ctdb.1.xml
index 1a1ae40..e95caa0 100644
--- a/ctdb/doc/ctdb.1.xml
+++ b/ctdb/doc/ctdb.1.xml
@@ -206,7 +206,7 @@
       <varlistentry><term>-d --debug=<parameter>DEBUGLEVEL</parameter></term>
       <listitem>
 	<para>
-	  Change the debug level for the command. Default is ERR (0).
+	  Change the debug level for the command. Default is NOTICE (2).
 	</para>
       </listitem>
       </varlistentry>
diff --git a/ctdb/doc/ctdbd.1.xml b/ctdb/doc/ctdbd.1.xml
index fc17acf..b5feea2 100644
--- a/ctdb/doc/ctdbd.1.xml
+++ b/ctdb/doc/ctdbd.1.xml
@@ -52,9 +52,7 @@
 	  <para>
 	    This option sets the debug level to DEBUGLEVEL, which
 	    controls what will be written by the logging
-	    subsystem. The default is 0 which will only log important
-	    events and errors. A larger number will provide additional
-	    logging.
+	    subsystem.  The default is 2.
 	  </para>
 	  <para>
 	    See the <citetitle>DEBUG LEVELS</citetitle> section in
diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml
index 52c1298..8a62c86 100644
--- a/ctdb/doc/ctdbd.conf.5.xml
+++ b/ctdb/doc/ctdbd.conf.5.xml
@@ -202,7 +202,7 @@
 	<term>CTDB_DEBUGLEVEL=<parameter>DEBUGLEVEL</parameter></term>
 	<listitem>
 	  <para>
-	    Default is ERR (0).  Corresponds to <option>-d</option> or
+	    Default is NOTICE (2).  Corresponds to <option>-d</option> or
 	    <option>--debug</option>.
 	  </para>
 	</listitem>
diff --git a/ctdb/server/ctdb_tunables.c b/ctdb/server/ctdb_tunables.c
index 544a9e0..e5ccf10 100644
--- a/ctdb/server/ctdb_tunables.c
+++ b/ctdb/server/ctdb_tunables.c
@@ -175,6 +175,7 @@ int32_t ctdb_control_set_tunable(struct ctdb_context *ctdb, TDB_DATA indata)
 		DEBUG(DEBUG_WARNING,
 		      ("Setting obsolete tunable \"%s\"\n",
 		       tunable_map[i].name));
+		return 1;
 	}
 
 	return 0;
diff --git a/ctdb/tests/eventscripts/10.interface.monitor.002.sh b/ctdb/tests/eventscripts/00.ctdb.setup.001.sh
similarity index 64%
copy from ctdb/tests/eventscripts/10.interface.monitor.002.sh
copy to ctdb/tests/eventscripts/00.ctdb.setup.001.sh
index ba33f92..1e094f8 100755
--- a/ctdb/tests/eventscripts/10.interface.monitor.002.sh
+++ b/ctdb/tests/eventscripts/00.ctdb.setup.001.sh
@@ -2,7 +2,7 @@
 
 . "${TEST_SCRIPTS_DIR}/unit.sh"
 
-define_test "all interfaces up"
+define_test "setup, no tunables in config"
 
 setup_ctdb
 
diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.002.sh b/ctdb/tests/eventscripts/00.ctdb.setup.002.sh
new file mode 100755
index 0000000..c62b83c
--- /dev/null
+++ b/ctdb/tests/eventscripts/00.ctdb.setup.002.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "setup, known tunables in config"
+
+setup_ctdb
+
+setup_config <<EOF
+CTDB_SET_MonitorInterval=5
+CTDB_SET_TDBMutexEnabled=0
+EOF
+
+required_result 0 <<EOF
+Set MonitorInterval to 5
+Set TDBMutexEnabled to 0
+EOF
+
+simple_test
diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.003.sh b/ctdb/tests/eventscripts/00.ctdb.setup.003.sh
new file mode 100755
index 0000000..4ce7040
--- /dev/null
+++ b/ctdb/tests/eventscripts/00.ctdb.setup.003.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "setup, known and unknown tunables in config"
+
+setup_ctdb
+
+setup_config <<EOF
+CTDB_SET_MonitorInterval=5
+CTDB_SET_UnknownMagic=0
+EOF
+
+required_result 1 <<EOF
+Set MonitorInterval to 5
+Unable to set tunable variable 'UnknownMagic'
+Invalid configuration: CTDB_SET_UnknownMagic=0
+Aborting setup due to invalid configuration - fix typos, remove unknown tunables
+EOF
+
+simple_test
diff --git a/ctdb/tests/eventscripts/00.ctdb.setup.004.sh b/ctdb/tests/eventscripts/00.ctdb.setup.004.sh
new file mode 100755
index 0000000..6fd2dbf
--- /dev/null
+++ b/ctdb/tests/eventscripts/00.ctdb.setup.004.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "setup, known and obsolete tunables in config"
+
+setup_ctdb
+
+setup_config <<EOF
+CTDB_SET_MonitorInterval=5
+CTDB_SET_EventScriptUnhealthyOnTimeout=0
+EOF
+
+required_result 0 <<EOF
+Setting obsolete tunable variable 'EventScriptUnhealthyOnTimeout'
+Set EventScriptUnhealthyOnTimeout to 0
+Set MonitorInterval to 5
+EOF
+
+simple_test
diff --git a/ctdb/tests/eventscripts/etc/sysconfig/ctdb b/ctdb/tests/eventscripts/etc/sysconfig/ctdb
index 4584c11..fe0436d 100644
--- a/ctdb/tests/eventscripts/etc/sysconfig/ctdb
+++ b/ctdb/tests/eventscripts/etc/sysconfig/ctdb
@@ -1,2 +1,6 @@
 CTDB_RECOVERY_LOCK="/some/place/on/shared/storage"
 CTDB_DEBUGLEVEL=ERR
+
+if [ -n "$FAKE_CTDB_EXTRA_CONFIG" -a -r "$FAKE_CTDB_EXTRA_CONFIG" ] ; then
+   . "$FAKE_CTDB_EXTRA_CONFIG"
+fi
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh
index 23a6481..f044ef8 100644
--- a/ctdb/tests/eventscripts/scripts/local.sh
+++ b/ctdb/tests/eventscripts/scripts/local.sh
@@ -296,6 +296,9 @@ setup_ctdb ()
 
     export FAKE_CTDB_STATE="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb"
 
+    export FAKE_CTDB_EXTRA_CONFIG="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-config.sh"
+    rm -f "$FAKE_CTDB_EXTRA_CONFIG"
+
     export FAKE_CTDB_IFACES_DOWN="$FAKE_CTDB_STATE/ifaces-down"
     mkdir -p "$FAKE_CTDB_IFACES_DOWN"
     rm -f "$FAKE_CTDB_IFACES_DOWN"/*
@@ -305,6 +308,14 @@ setup_ctdb ()
     rm -f "$FAKE_CTDB_SCRIPTSTATUS"/*
 
     export CTDB_PARTIALLY_ONLINE_INTERFACES
+
+    export FAKE_CTDB_TUNABLES_OK="MonitorInterval TDBMutexEnabled DatabaseHashSize"
+    export FAKE_CTDB_TUNABLES_OBSOLETE="EventScriptUnhealthyOnTimeout"
+}
+
+setup_config ()
+{
+    cat >"$FAKE_CTDB_EXTRA_CONFIG"
 }
 
 setup_memcheck ()
diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb
index c444196..cdb6013 100755
--- a/ctdb/tests/eventscripts/stubs/ctdb
+++ b/ctdb/tests/eventscripts/stubs/ctdb
@@ -304,6 +304,31 @@ ctdb_natgwlist ()
 
 ######################################################################
 
+ctdb_setvar ()
+{
+    shift
+    _var="$1"
+
+    for _i in $FAKE_CTDB_TUNABLES_OK ; do
+	if [ "$_var" = "$_i" ] ; then
+	    return 0
+	fi
+    done
+
+    for _i in $FAKE_CTDB_TUNABLES_OBSOLETE ; do
+	if [ "$_var" = "$_i" ] ; then
+	    echo "Setting obsolete tunable variable '${_var}'"
+	    return 0
+	fi
+    done
+
+    echo "Unable to set tunable variable '${_var}'"
+    return 1
+}
+
+
+######################################################################
+
 case "$1" in
     gettickles)
 	setup_tickles
@@ -405,5 +430,6 @@ case "$1" in
     shutdown)      ctdb_shutdown "$@";;
     setnatgwstate) ctdb_setnatgwstate "$@" ;;
     natgwlist)     ctdb_natgwlist "$@" ;;
+    setvar)	   ctdb_setvar "$@" ;;
     *) not_implemented "$1" ;;
 esac
diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c
index 4654f3c..b420dcd 100644
--- a/ctdb/tools/ctdb.c
+++ b/ctdb/tools/ctdb.c
@@ -4839,6 +4839,11 @@ static int control_setvar(struct ctdb_context *ctdb, int argc, const char **argv
 		DEBUG(DEBUG_ERR, ("Unable to set tunable variable '%s'\n", name));
 		return -1;
 	}
+	if (ret == 1) {
+		DEBUG(DEBUG_WARNING,
+		      ("Setting obsolete tunable variable '%s'\n",
+		       name));
+	}
 	return 0;
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list