[SCM] Samba Shared Repository - branch master updated

Amitay Isaacs amitay at samba.org
Sun Apr 26 22:11:03 MDT 2015


The branch, master has been updated
       via  0621f07 ctdb-scripts: New configuration variable CTDB_NODE_ADDRESS
       via  b38137a ctdb-doc: Move --listen documentation from debugging options
       via  0ae5758 ctdb-scripts: Simplify a command pipeline
       via  1092f97 ctdb-scripts: Replace uses of "ctdb pnn" with ctdb_get_pnn()
       via  09b5e49 ctdb-scripts: Changed uses of "ctdb xpnn" to ctdb_get_pnn()
       via  af93ae1 ctdb-tests: New function ctdb_set_pnn() to change PNN
       via  579dda6 ctdb-scripts: New function ctdb_get_pnn() does cached retrieval of PNN
      from  ec085fe Revert "wafsamba: flags from enviroment are put before our own internal versions"

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


- Log -----------------------------------------------------------------
commit 0621f07eb482daf7495f6314b0af32853573cb82
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 20 09:53:23 2015 +1000

    ctdb-scripts: New configuration variable CTDB_NODE_ADDRESS
    
    Required when automatic address detection can not be used.  This can
    be the case when running multiple ctdbd daemons/nodes on the same
    physical host (usually for testing), using InfiniBand for the private
    network or on Linux when sysctl net.ipv4.ip_nonlocal_bind=1.
    
    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): Mon Apr 27 06:10:08 CEST 2015 on sn-devel-104

commit b38137a3898afc86348404af4435beb44d3493be
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon Apr 20 09:18:08 2015 +1000

    ctdb-doc: Move --listen documentation from debugging options
    
    There are valid real-world use cases.  Improve the documentation.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 0ae57588eb99ef18888a8ace25a49efef1301fff
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Apr 19 19:52:55 2015 +1000

    ctdb-scripts: Simplify a command pipeline
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 1092f9755fed331251ae508f1e04e85dc47ae902
Author: Martin Schwenke <martin at meltin.net>
Date:   Sun Apr 19 19:45:41 2015 +1000

    ctdb-scripts: Replace uses of "ctdb pnn" with ctdb_get_pnn()
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 09b5e4978ab1df09f47156147848a6bf099ea665
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Apr 18 22:00:49 2015 +1000

    ctdb-scripts: Changed uses of "ctdb xpnn" to ctdb_get_pnn()
    
    "ctdb xpnn" does not work when sysctl net.ipv4.ip_nonlocal_bind=1,
    since it determines the node by attempting to bind to each addres in
    the nodes file.  The solution is to not use "ctdb xpnn".  After the
    initial call, ctdb_get_pnn() will be more efficient that "ctdb xpnn".
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit af93ae1a540003824b32301d3c9f09c713f1fa7a
Author: Martin Schwenke <martin at meltin.net>
Date:   Sat Apr 18 21:55:50 2015 +1000

    ctdb-tests: New function ctdb_set_pnn() to change PNN
    
    ctdb_get_pnn() incorrectly caches to the same file regardless of what
    node is selected via FAKE_CTDB_PNN.
    
    Instead, set the PNN using new function ctdb_get_pnn(), which also
    makes CTDB_VARDIR point to a node-specific subdirectory.  This means
    that ctdb_get_pnn() will correctly cache to the node-specific
    directory.
    
    Fake tickle and TDB files/directories used by the ctdb stub need to be
    the same across all PNNs, so change these to use
    $EVENTSCRIPTS_TESTS_VAR_DIR instead of node-specific $CTDB_VARDIR.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

commit 579dda6858f547d360073cd67235e49ab03b355e
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Apr 17 20:44:15 2015 +1000

    ctdb-scripts: New function ctdb_get_pnn() does cached retrieval of PNN
    
    This avoids the expense of establishing a client connection to the
    daemon just to get the PNN of the current node.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>

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

Summary of changes:
 ctdb/config/ctdbd_wrapper                    |  1 +
 ctdb/config/events.d/00.ctdb                 |  3 +-
 ctdb/config/events.d/11.natgw                |  4 +--
 ctdb/config/events.d/62.cnfs                 |  4 +--
 ctdb/config/events.d/70.iscsi                |  7 ++---
 ctdb/config/events.d/91.lvs                  |  6 ++--
 ctdb/config/functions                        | 19 ++++++++++--
 ctdb/config/statd-callout                    |  8 +++---
 ctdb/doc/ctdbd.1.xml                         | 43 ++++++++++++++--------------
 ctdb/doc/ctdbd.conf.5.xml                    | 23 +++++++++++++++
 ctdb/tests/eventscripts/scripts/local.sh     | 19 ++++++++----
 ctdb/tests/eventscripts/statd-callout.005.sh |  6 ++--
 ctdb/tests/eventscripts/statd-callout.006.sh |  6 ++--
 ctdb/tests/eventscripts/stubs/ctdb           |  4 +--
 14 files changed, 99 insertions(+), 54 deletions(-)


Changeset truncated at 500 lines:

diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index f50efe9..aac8369 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -114,6 +114,7 @@ build_ctdb_options ()
     maybe_set "--logging"                "$CTDB_LOGGING"
     maybe_set "--nlist"                  "$CTDB_NODES"
     maybe_set "--socket"                 "$CTDB_SOCKET"
+    maybe_set "--listen"                 "$CTDB_NODE_ADDRESS"
     maybe_set "--public-addresses"       "$CTDB_PUBLIC_ADDRESSES"
     maybe_set "--public-interface"       "$CTDB_PUBLIC_INTERFACE"
     maybe_set "--dbdir"                  "$CTDB_DBDIR"
diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index 07bc7a7..0688411 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -103,7 +103,8 @@ EOF
 update_config_from_tdb() {
 
     # Pull optional ctdb configuration data out of config.tdb
-    _key="public_addresses:node#$(ctdb -t 1 xpnn|sed -e 's/.*://')"
+    ctdb_get_pnn
+    _key="public_addresses:node#${pnn}"
     _t="$service_state_dir/public_addresses"
     rm -f "$_t"
 
diff --git a/ctdb/config/events.d/11.natgw b/ctdb/config/events.d/11.natgw
index e107f47..54e6cd9 100755
--- a/ctdb/config/events.d/11.natgw
+++ b/ctdb/config/events.d/11.natgw
@@ -208,7 +208,7 @@ case "$1" in
     updatenatgw|ipreallocated)
 	natgw_check_config
 
-	mypnn=$(ctdb pnn | cut -d: -f2)
+	ctdb_get_pnn
 
 	natgw_set_capability
 	natgw_ensure_master
@@ -217,7 +217,7 @@ case "$1" in
 
 	natgw_clear
 
-	if [ "$mypnn" = "$natgwmaster" ]; then
+	if [ "$pnn" = "$natgwmaster" ]; then
 	    natgw_set_master
 	else
 	    natgw_set_slave "$natgwip"
diff --git a/ctdb/config/events.d/62.cnfs b/ctdb/config/events.d/62.cnfs
index a6ca0c4..339eaef 100755
--- a/ctdb/config/events.d/62.cnfs
+++ b/ctdb/config/events.d/62.cnfs
@@ -52,8 +52,8 @@ case "$1" in
         ctdb eventscript monitor
 
         # Wait until we no longer serve any ip addresses at all
-        PNN=`ctdb pnn | cut -d: -f2`
-        while `ctdb -X ip | cut -d'|' -f3 | egrep "^$PNN$" >/dev/null`; do
+	ctdb_get_pnn
+	while ctdb -X ip | grep -q "^|.*|${pnn}|\$" ; do
                 sleep 1
         done
         ;;
diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi
index 42d261b..33b71c4 100755
--- a/ctdb/config/events.d/70.iscsi
+++ b/ctdb/config/events.d/70.iscsi
@@ -47,15 +47,14 @@ EOF
 	# Stop iSCSI daemon
 	killall -9 tgtd >/dev/null 2>/dev/null
 
-	# What node is this?
-	this_node=$(ctdb xpnn | sed -e 's at PNN:@@')
-	[ -n "$this_node" ] || die "Failed to get node pnn"
+	ctdb_get_pnn
+	[ -n "$pnn" ] || die "Failed to get node pnn"
 
 	# Start iSCSI daemon
 	tgtd >/dev/null 2>&1
 
 	# Run a script for each currently hosted public IP address
-	ips=$(echo "$all_ips" | awk -F'|' -v pnn=$this_node '$3 == pnn {print $2}')
+	ips=$(echo "$all_ips" | awk -F'|' -v pnn=$pnn '$3 == pnn {print $2}')
 	for ip in $ips ; do
 	    script="${CTDB_START_ISCSI_SCRIPTS}/${ip}.sh"
 	    if [ -x "$script" ] ; then
diff --git a/ctdb/config/events.d/91.lvs b/ctdb/config/events.d/91.lvs
index bdbcfa3..47adf33 100755
--- a/ctdb/config/events.d/91.lvs
+++ b/ctdb/config/events.d/91.lvs
@@ -46,10 +46,10 @@ case "$1" in
 	ipvsadm -D -u $CTDB_LVS_PUBLIC_IP:0
 	kill_tcp_connections_local_only $CTDB_LVS_PUBLIC_IP
 
-	PNN=`ctdb pnn | sed -e "s/.*PNN://"`
+	ctdb_get_pnn
 	LVSMASTER=`ctdb lvsmaster | sed -e "s/.*Node //" -e "s/ .*//"`
 
-	[ "$PNN" != "$LVSMASTER" ] && {
+	[ "$pnn" != "$LVSMASTER" ] && {
 	    # we are not the lvs master so we have to
 	    # change the ip address to have scope host so we wont respond
 	    # to arps
@@ -66,7 +66,7 @@ case "$1" in
 	ipvsadm -A -u $CTDB_LVS_PUBLIC_IP:0 -p 1999999 -s lc
 
 	# add all nodes (except ourselves) to the lvs config
-	ctdb lvs | egrep -v "^$PNN:" | sed -e "s/.*://" | while read IP; do
+	ctdb lvs | egrep -v "^${pnn}:" | sed -e "s/.*://" | while read IP; do
 		ipvsadm -a -t $CTDB_LVS_PUBLIC_IP:0 -r $IP -g
 		ipvsadm -a -u $CTDB_LVS_PUBLIC_IP:0 -r $IP -g
 	done
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 1b2384e..96da817 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -199,6 +199,20 @@ nice_service()
 }
 
 ######################################################
+# Cached retrieval of PNN from local node.  This never changes so why
+# open a client connection to the server each time this is needed?
+# This sets $pnn - this avoid an unnecessary subprocess.
+ctdb_get_pnn ()
+{
+    _pnn_file="$CTDB_VARDIR/state/my-pnn"
+    if [ ! -f "$_pnn_file" ] ; then
+	ctdb pnn | sed -e 's at .*:@@' >"$_pnn_file"
+    fi
+
+    read pnn <"$_pnn_file"
+}
+
+######################################################
 # wrapper around /proc/ settings to allow them to be hooked
 # for testing
 # 1st arg is relative path under /proc/, 2nd arg is value to set
@@ -1441,11 +1455,10 @@ update_tickles ()
 	tickledir="$CTDB_VARDIR/state/tickles"
 	mkdir -p "$tickledir"
 
-	# Who am I?
-	_pnn=$(ctdb pnn) ; _pnn=${_pnn#PNN:}
+	ctdb_get_pnn
 
 	# What public IPs do I hold?
-	_ips=$(ctdb -X ip | awk -F'|' -v pnn=$_pnn '$3 == pnn {print $2}')
+	_ips=$(ctdb -X ip | awk -F'|' -v pnn=$pnn '$3 == pnn {print $2}')
 
 	# IPs as a regexp choice
 	_ipschoice="($(echo $_ips | sed -e 's/ /|/g' -e 's/\./\\\\./g'))"
diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index 4a331ac..347af41 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -47,7 +47,7 @@ case "$1" in
 	# statd does not tell us to which IP the client connected so
 	# we must add it to all the IPs that we serve
 	cip="$2"
-	pnn=$(ctdb xpnn | sed -e 's/.*://')
+	ctdb_get_pnn
 	date=$(date '+%s')
 	ctdb ip -X |
 	tail -n +2 |
@@ -62,7 +62,7 @@ case "$1" in
 	# statd does not tell us from which IP the client disconnected
 	# so we must add it to all the IPs that we serve
 	cip="$2"
-	pnn=$(ctdb xpnn | sed -e 's/.*://')
+	ctdb_get_pnn
 	ctdb ip -X |
 	tail -n +2 |
 	while IFS="|" read x sip node x ; do
@@ -80,7 +80,7 @@ case "$1" in
 	fi
 	# Filter out lines for any IP addresses that are not currently
 	# hosted public IP addresses.
-	pnn=$(ctdb xpnn | sed -e 's/.*://')
+	ctdb_get_pnn
 	ctdb_ips=$(ctdb ip | tail -n +2)
 	sed_expr=$(echo "$ctdb_ips" |
 	    awk -v pnn=$pnn 'pnn == $2 { \
@@ -156,7 +156,7 @@ case "$1" in
 	# probability that the client will accept the statd notify packet and
 	# not just ignore it.
 	# For all IPs we serve, collect info and push to the config database
-	pnn=$(ctdb xpnn | sed -e 's/.*://')
+	ctdb_get_pnn
 
 	# Construct a sed expression to take catdb output and produce pairs of:
 	#   server-IP client-IP
diff --git a/ctdb/doc/ctdbd.1.xml b/ctdb/doc/ctdbd.1.xml
index b5feea2..558e534 100644
--- a/ctdb/doc/ctdbd.1.xml
+++ b/ctdb/doc/ctdbd.1.xml
@@ -126,6 +126,28 @@
       </varlistentry>
 
       <varlistentry>
+	<term>--listen=<parameter>IPADDR</parameter></term>
+	<listitem>
+	  <para>
+	    IPADDR is the private IP address that ctdbd will bind to.
+	  </para>
+	  <para>
+	    By default ctdbd will select the first address from the
+	    nodes list that in can bind to.  See also
+	    <citetitle>--nlist</citetitle>.
+	  </para>
+	  <para>
+	    This option is only required when automatic address
+	    detection can not be used.  This can be the case when
+	    running multiple ctdbd daemons/nodes on the same physical
+	    host (usually for testing), using InfiniBand for the
+	    private network or on Linux when sysctl
+	    net.ipv4.ip_nonlocal_bind=1.
+	  </para>
+	</listitem>
+      </varlistentry>
+
+      <varlistentry>
 	<term>--logging=<parameter>STRING</parameter></term>
 	<listitem>
 	  <para>
@@ -486,27 +508,6 @@
       </varlistentry>
 
       <varlistentry>
-	<term>--listen=<parameter>IPADDR</parameter></term>
-	<listitem>
-	  <para>
-	    This specifies which IP address that ctdbd will bind to.
-	  </para>
-	  <para>
-	    By default ctdbd will bind to the first address it finds in
-	    the <filename>/etc/ctdb/nodes</filename> file that is also
-	    present on the local system.
-	  </para>
-	  <para>
-	    This option is only required when you want to run multiple
-	    ctdbd daemons/nodes on the same physical host in which case
-	    there would be multiple entries in
-	    <filename>/etc/ctdb/nodes</filename> that would match a
-	    local interface.
-	  </para>
-	</listitem>
-      </varlistentry>
-
-      <varlistentry>
 	<term>--nopublicipcheck</term>
 	<listitem>
 	  <para>
diff --git a/ctdb/doc/ctdbd.conf.5.xml b/ctdb/doc/ctdbd.conf.5.xml
index 8a62c86..cc56d79 100644
--- a/ctdb/doc/ctdbd.conf.5.xml
+++ b/ctdb/doc/ctdbd.conf.5.xml
@@ -344,6 +344,29 @@
       </varlistentry>
 
       <varlistentry>
+	<term>CTDB_NODE_ADDRESS=<parameter>FILENAME</parameter></term>
+	<listitem>
+	  <para>
+	    IPADDR is the private IP address that ctdbd will bind to.
+	    Corresponds to <option>--listen</option>.
+	  </para>
+	  <para>
+	    By default ctdbd will select the first address from the
+	    nodes list that in can bind to.  See also
+	    <citetitle>CTDB_NODES</citetitle>.
+	  </para>
+	  <para>
+	    This option is only required when automatic address
+	    detection can not be used.  This can be the case when
+	    running multiple ctdbd daemons/nodes on the same physical
+	    host (usually for testing), using InfiniBand for the
+	    private network or on Linux when sysctl
+	    net.ipv4.ip_nonlocal_bind=1.
+	  </para>
+	</listitem>
+      </varlistentry>
+
+      <varlistentry>
 	<term>CTDB_PUBLIC_ADDRESSES=<parameter>FILENAME</parameter></term>
 	<listitem>
 	  <para>
diff --git a/ctdb/tests/eventscripts/scripts/local.sh b/ctdb/tests/eventscripts/scripts/local.sh
index aba53e8..ae30414 100644
--- a/ctdb/tests/eventscripts/scripts/local.sh
+++ b/ctdb/tests/eventscripts/scripts/local.sh
@@ -303,6 +303,18 @@ setup_public_addresses ()
 EOF
 }
 
+# Need to cope with ctdb_get_pnn().  If a test changes PNN then it
+# needs to be using a different state directory, otherwise the wrong
+# PNN can already be cached in the state directory.
+ctdb_set_pnn ()
+{
+    export FAKE_CTDB_PNN="$1"
+    echo "Setting up PNN ${FAKE_CTDB_PNN}"
+
+    export CTDB_VARDIR="$EVENTSCRIPTS_TESTS_VAR_DIR/ctdb/${FAKE_CTDB_PNN}"
+    mkdir -p "$CTDB_VARDIR"
+}
+
 setup_ctdb ()
 {
     setup_generic
@@ -310,8 +322,7 @@ setup_ctdb ()
     export FAKE_CTDB_NUMNODES="${1:-3}"
     echo "Setting up CTDB with ${FAKE_CTDB_NUMNODES} fake nodes"
 
-    export FAKE_CTDB_PNN="${2:-0}"
-    echo "Setting up CTDB with PNN ${FAKE_CTDB_PNN}"
+    ctdb_set_pnn "${2:-0}"
 
     setup_public_addresses
 
@@ -747,10 +758,6 @@ setup_samba ()
 	export FAKE_TCP_LISTEN=""
 	export FAKE_WBINFO_FAIL="yes"
     fi
-
-    # This is ugly but if this file isn't removed before each test
-    # then configuration changes between tests don't stick.
-    rm -f "$CTDB_VARDIR/state/samba/smb.conf.cache"
 }
 
 setup_winbind ()
diff --git a/ctdb/tests/eventscripts/statd-callout.005.sh b/ctdb/tests/eventscripts/statd-callout.005.sh
index ceb4445..06d4a1f 100755
--- a/ctdb/tests/eventscripts/statd-callout.005.sh
+++ b/ctdb/tests/eventscripts/statd-callout.005.sh
@@ -12,16 +12,16 @@ ok_null
 simple_test_event "add-client" "192.168.123.45"
 simple_test_event "update"
 
-FAKE_CTDB_PNN=1
+ctdb_set_pnn 1
 
 ok_null
 simple_test_event "add-client" "192.168.123.46"
 simple_test_event "update"
 
-FAKE_CTDB_PNN=0
+ctdb_set_pnn 0
 
 check_statd_callout_smnotify "192.168.123.45"
 
-FAKE_CTDB_PNN=1
+ctdb_set_pnn 1
 
 check_ctdb_tdb_statd_state "192.168.123.46"
diff --git a/ctdb/tests/eventscripts/statd-callout.006.sh b/ctdb/tests/eventscripts/statd-callout.006.sh
index 0db86fe..edeeda8 100755
--- a/ctdb/tests/eventscripts/statd-callout.006.sh
+++ b/ctdb/tests/eventscripts/statd-callout.006.sh
@@ -12,17 +12,17 @@ ok_null
 simple_test_event "add-client" "192.168.123.45"
 simple_test_event "update"
 
-FAKE_CTDB_PNN=1
+ctdb_set_pnn 1
 
 ok_null
 simple_test_event "add-client" "192.168.123.46"
 simple_test_event "update"
 
-FAKE_CTDB_PNN=0
+ctdb_set_pnn 0
 
 check_statd_callout_smnotify "192.168.123.45"
 
-FAKE_CTDB_PNN=1
+ctdb_set_pnn 1
 
 check_statd_callout_smnotify "192.168.123.46"
 
diff --git a/ctdb/tests/eventscripts/stubs/ctdb b/ctdb/tests/eventscripts/stubs/ctdb
index 7dbb6b4..aa3ac73 100755
--- a/ctdb/tests/eventscripts/stubs/ctdb
+++ b/ctdb/tests/eventscripts/stubs/ctdb
@@ -54,7 +54,7 @@ done
 setup_tickles ()
 {
     # Make sure tickles file exists.
-    tickles_file="$CTDB_VARDIR/fake-ctdb/tickles"
+    tickles_file="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb/tickles"
     mkdir -p $(dirname "$tickles_file")
     touch "$tickles_file"
 }
@@ -336,7 +336,7 @@ ctdb_setvar ()
 
 _t_setup ()
 {
-    _t_dir="$CTDB_VARDIR/fake-ctdb/fake-tdb/$1"
+    _t_dir="$EVENTSCRIPTS_TESTS_VAR_DIR/fake-ctdb/fake-tdb/$1"
     mkdir -p "$_t_dir"
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list