[PATCHES] make ctdb runnable in non-FHS installs

Michael Adam obnox at samba.org
Wed Jun 8 14:51:19 UTC 2016


Attached find the updated patchset that implements
the changes from our discussion.

It also covers a few cases of direct use of 'ctdb'
that I did not catch before.

But beware that this is not for pushing yet:

This implements the rename of ctdb->ctdb_tool
and establishes the former ctdb_wrapper as
discussed. While this works nicely from an
install, it does (as I feared) put up some
problems with selftest, since the 'ctdb' tool
is used (verbatim) in the tests. And also,
afaict the ctdb wrapper tool is only prepared
during 'make install' not during 'make'.

So we have several options out of this:
1) Either refrain from renaming ctdb->ctdb_tool
   and keep ctdb_wrapper for a start,
2) or stick with the renaming and rename all
   use of 'ctdb' to ctdb_tool in the tests
3) or somehow make sure that ctdb (wrapper)
   (and possibly ctdbd_wrapper) are prepared
   during make and can be used in the tests.

Not sure. #1 would be the least effort and might
be a good start. #2 would be a bigger sweeping
rename, and #3 might be conceptually better,
but requires some wscript voodoo that at least
I'd have to think about for some time.

Opinions?

Cheers - Michael



On 2016-06-08 at 11:39 +0200, Michael Adam wrote:
> Thanks for the review, Martin!
> 
> On 2016-06-08 at 11:28 +1000, Martin Schwenke wrote:
> > On Wed, 8 Jun 2016 01:30:02 +0200, Michael Adam <obnox at samba.org> wrote:
> > 
> > > While debugging an issue with ctdb, I thought (again)
> > > it would be convenient to be able to run ctdb(d) in
> > > an install that is not conforming to FHS.
> > > 
> > > We do already have ctdbd_wrapper to call the daemon,
> > > but several places in event scripts and ctdbd_wrapper
> > > itself directly call ctdbd. So this assumes that ctdb
> > > is in the patch and is to be called without options.
> > > Hence running from a non-fhs install-prefix does not
> > > work at all.
> > > 
> > > This patch introduces ctdb_wrapper (like ctdbdb_wrapper)
> > > but for the ctdb tool and much simpler, and it changes
> > > all important places (event scripts and ctdbd_wrapper) to
> > > call ctdb_wrapper instead of calling ctdb direclty.
> > > 
> > > So this patchset lets me successfully start and manage
> > > a ctdb cluster from a non-FHS location.
> > > 
> > > Review appreciated!
> > 
> > Thanks!  I've been wanting to do something like this for a long time!
> > 
> > Comments:
> > 
> > * I don't think using "eval" gains you anything.  In most places you can
> >   just change:
> > 
> >     ctdb -> $ctdb
> > 
> >   I think the exception is the wrapper.  I think the eval is needed
> >   there because the wrapper adds single-quotes quotes around option
> >   values so it can then maintain whitespace in the values when the
> >   command-line is expanded using eval.  It might be work testing if
> >   that actually works and, if not, we could simplify and allow
> >   ctdb_wrapper to just use exec.  Similarly, we could decide to
> >   simplify the code by not allowing whitespace in option values.  Blah,
> >   blah, blah...  :-)
> 
> Thanks. I am never 100% sure about the usefulness of and
> need to use eval. I just imitated patterns I saw elsewhere. :-)
> 
> So I'll simply go with your advice and (for now) only leave
> the use in ctdbd_wrapper eval'd.
> 
> > * Copying and using maybe_set() only once is probably overkill.  I'd
> >   suggest either:
> > 
> >   1. Moving it to the functions file (since it is loaded anyway),
> >      perhaps with a rename (ctdb_options_maybe_set ?) and still calling
> >      it.  This makes sense if we want to add more options.  Perhaps
> >      CTDB_NODES, which is pulled from environment by ctdb command?
> > 
> >   2. Just inline the construction of ctdb_options.
> > 
> >   I think I prefer (1).  :-)
> 
> Good point, i'll change it accordingly.
> 
> > * I think you're solving 2 problems here:
> > 
> >   1. Help the event scripts find the ctdb command.
> > 
> >   2. Help the ctdb command process configuration options.
> 
> Very true.
> 
> >   Because (2) is valuable to external callers too, I wonder if you want
> >   to change things so that /usr/local/bin/ctdb is the wrapper
> >   and /usr/local/libexec/ctdb/ctdb_tool (or ctdb_cli, or similar) is
> >   the binary.  Then everyone gets (2).  Then we can still do (1) by
> >   using CTDB_TOOL="${CTDB_TOOL:-/usr/local/bin/ctdb}", or similar.
> > 
> > What do you think?
> 
> I thought the same thing actually, but I feared it would
> be considered too radical. Hence I did not dare to propose
> it. But your suggestion confirms my ideas.
> 
> I'll post a second version of the patchset with the above
> changes, soon!
> 
> Cheers - Michael


-------------- next part --------------
From 35d17d134e0c05478b0495f8bf6f8fb792c382d7 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 11:53:12 +0200
Subject: [PATCH 01/16] ctdb: rename the binary ctdb to ctdb_tool

This is in preparation of adding a shell wrapper
that reads the config to detect the socket, so
that it will be possible to call ctdb directly
with less trouble.

Note that this leaves the ctdb.1 manpage unchanged.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/wscript | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/wscript b/ctdb/wscript
index 744ba96..818cfef 100755
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -414,7 +414,7 @@ def build(bld):
                      install_path='${SBINDIR}',
                      manpages='ctdbd.1')
 
-    bld.SAMBA_BINARY('ctdb',
+    bld.SAMBA_BINARY('ctdb_tool',
                      source='tools/ctdb.c',
                      deps='ctdb-client ctdb-common ctdb-system ctdb-util',
                      includes='include',
-- 
2.5.5


From a1782a5f68f37fe4f5142e3b00c3dd1d0806fd23 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 11:46:00 +0200
Subject: [PATCH 02/16] ctdb: move mabye_set from ctdbd_wrapper to functions
 for re-use

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/ctdbd_wrapper | 22 ----------------------
 ctdb/config/functions     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index b1f71c3..192b20d 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -116,28 +116,6 @@ build_ctdb_options ()
 {
     ctdb_options=""
 
-    maybe_set ()
-    {
-	# If the given variable isn't set then do nothing
-	[ -n "$2" ] || return
-	# If a required value for the variable and it doesn't match,
-	# then do nothing
-	[ -z "$3" -o "$3" = "$2" ] || return
-
-	val="'$2'"
-	case "$1" in
-	    --*) sep="=" ;;
-	    -*)  sep=" " ;;
-	esac
-	# For these options we're only passing a value-less flag.
-	if [ -n "$3" ] ; then
-	    val=""
-	    sep=""
-	fi
-
-	ctdb_options="${ctdb_options}${ctdb_options:+ }${1}${sep}${val}"
-    }
-
     if [ -z "$CTDB_RECOVERY_LOCK" ] ; then
         echo "No recovery lock specified. Starting CTDB without split brain prevention."
     fi
diff --git a/ctdb/config/functions b/ctdb/config/functions
index 33efa51..dc63a5f 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -24,6 +24,37 @@ if [ -z "$CTDB_HELPER_BINDIR" ] ; then
     CTDB_HELPER_BINDIR="/usr/local/libexec/ctdb"
 fi
 
+
+#########################################
+# Convert environment variables into
+# commandline options or ctdbd and ctdb.
+#
+# The options are stored in the variable
+# ctdb_options that the caller should have
+# initialized.
+maybe_set ()
+{
+	# If the given variable isn't set then do nothing
+	[ -n "$2" ] || return
+	# If a required value for the variable and it doesn't match,
+	# then do nothing
+	[ -z "$3" -o "$3" = "$2" ] || return
+
+	val="'$2'"
+	case "$1" in
+	    --*) sep="=" ;;
+	    -*)  sep=" " ;;
+	esac
+	# For these options we're only passing a value-less flag.
+	if [ -n "$3" ] ; then
+	    val=""
+	    sep=""
+	fi
+
+	ctdb_options="${ctdb_options}${ctdb_options:+ }${1}${sep}${val}"
+}
+
+
 #######################################
 # pull in a system config file, if any
 
-- 
2.5.5


From 2ec7dd61992d1cf9dde4586655b3f02bcad9064c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 7 Jun 2016 07:36:26 +0000
Subject: [PATCH 03/16] ctdb: add ctdb as a wrapper to call ctdb_tool

This is useful for non-standard installations since
it reads the socket from the config file so the user
does not need to specify it.

This is similar to ctdbd_wrapper for ctdbd but
much more simple.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/ctdb | 35 +++++++++++++++++++++++++++++++++++
 ctdb/wscript     | 12 ++++++++++--
 2 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100755 ctdb/config/ctdb

diff --git a/ctdb/config/ctdb b/ctdb/config/ctdb
new file mode 100755
index 0000000..f1154fd
--- /dev/null
+++ b/ctdb/config/ctdb
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# ctdb_tool wrapper - run the right ctdb with the right socket option
+
+############################################################
+
+if [ -z "$CTDB_BASE" ] ; then
+	export CTDB_BASE="/usr/local/etc/ctdb"
+fi
+
+. "${CTDB_BASE}/functions"
+loadconfig "ctdb"
+
+ctdb_tool="${CTDB_TOOL:-/usr/local/bin/ctdb_tool}"
+
+build_ctdb_options ()
+{
+	ctdb_options=""
+
+	maybe_set "--socket" "$CTDB_SOCKET"
+}
+
+############################################################
+
+build_ctdb_options
+
+if [ -n "$CTDB_VALGRIND" -a "$CTDB_VALGRIND" != "no" ] ; then
+	if [ "$CTDB_VALGRIND" = "yes" ] ; then
+		CTDB_VALIGRIND="valgrind -q --log-file=/usr/local/var/log/ctdb_valgrind"
+	fi
+	ctdb_tool="${CTDB_VALGRIND} ${ctdb_tool}"
+	ctdb_options="${ctdb_options} --valgrinding"
+fi
+
+eval "$ctdb_tool" "$ctdb_options" "$@"
diff --git a/ctdb/wscript b/ctdb/wscript
index 818cfef..ab48efe 100755
--- a/ctdb/wscript
+++ b/ctdb/wscript
@@ -513,9 +513,10 @@ def build(bld):
     sed_expr4 = 's|/usr/local/var/run/ctdb|%s|g'  % (bld.env.CTDB_RUNDIR)
     sed_expr5 = 's|/usr/local/sbin|%s|g'          % (bld.env.SBINDIR)
     sed_expr6 = 's|/usr/local/libexec/ctdb|%s|g'  % (bld.env.CTDB_HELPER_BINDIR)
-    sed_cmdline = '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
+    sed_expr7 = 's|/usr/local/bin|%s|g'           % (bld.env.BINDIR)
+    sed_cmdline = '-e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s" -e "%s"' % \
                        (sed_expr1, sed_expr2, sed_expr3, sed_expr4, sed_expr5,
-                        sed_expr6)
+                        sed_expr6, sed_expr7)
 
     for f in manpages:
         x = '%s.xml' % (f)
@@ -571,6 +572,13 @@ def build(bld):
     bld.INSTALL_FILES('${SBINDIR}', 'ctdbd_wrapper',
                       destname='ctdbd_wrapper', chmod=0755)
 
+    bld.SAMBA_GENERATOR('ctdb',
+                        source='config/ctdb',
+                        target='ctdb',
+                        rule='sed %s ${SRC} > ${TGT}' % (sed_cmdline))
+    bld.INSTALL_FILES('${BINDIR}', 'ctdb',
+                      destname='ctdb', chmod=0755)
+
     def SUBDIR_MODE_callback(arg, dirname, fnames):
         for f in fnames:
             fl = os.path.join(dirname, f)
-- 
2.5.5


From 9f65db5637eb8393e5169e577a110edcc34dcb44 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 12:08:35 +0200
Subject: [PATCH 04/16] ctdb: set the path to 'ctdb' in 'functions'

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/functions | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ctdb/config/functions b/ctdb/config/functions
index dc63a5f..30b9e72 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -10,6 +10,8 @@ fi
 CTDB_VARDIR="/usr/local/var/lib/ctdb"
 ctdb_rundir="/usr/local/var/run/ctdb"
 
+CTDB="${CTDB:-/usr/local/bin/ctdb}"
+
 # Only (and always) override these variables in test code
 
 if [ -z "$CTDB_SCRIPT_VARDIR" ] ; then
-- 
2.5.5


From c110d163d6b7d463b98f0e4874f20e777011f690 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 12:28:36 +0200
Subject: [PATCH 05/16] ctdb: use properly configured ctdb in functions

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/functions | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/ctdb/config/functions b/ctdb/config/functions
index 30b9e72..9aa7dad 100755
--- a/ctdb/config/functions
+++ b/ctdb/config/functions
@@ -276,7 +276,7 @@ ctdb_get_pnn ()
 {
     _pnn_file="${CTDB_SCRIPT_VARDIR}/my-pnn"
     if [ ! -f "$_pnn_file" ] ; then
-	ctdb pnn | sed -e 's at .*:@@' >"$_pnn_file"
+	$CTDB pnn | sed -e 's at .*:@@' >"$_pnn_file"
     fi
 
     read pnn <"$_pnn_file"
@@ -288,7 +288,7 @@ ctdb_get_ip_address ()
 {
     _ip_addr_file="${CTDB_SCRIPT_VARDIR}/my-ip-address"
     if [ ! -f "$_ip_addr_file" ] ; then
-	ctdb -X nodestatus |
+	$CTDB -X nodestatus |
 	    awk -F '|' 'NR == 2 { print $3 }' >"$_ip_addr_file"
     fi
 
@@ -411,7 +411,7 @@ ctdb_check_tcp_ports()
     fi
 
     for _p ; do  # process each function argument (port)
-	_cmd="ctdb checktcpport $_p"
+	_cmd="$CTDB checktcpport $_p"
 	_out=$($_cmd 2>&1)
 	_ret=$?
 	case "$_ret" in
@@ -433,7 +433,7 @@ ctdb_check_tcp_ports()
 	    *)
 		echo "ERROR: unexpected error running \"ctdb checktcpport\""
 		debug <<EOF
-ctdb checktcpport (exited with $_ret) with output:
+$CTDB checktcpport (exited with $_ret) with output:
 $_out"
 EOF
 		return $_ret
@@ -551,9 +551,9 @@ tickle_tcp_connections ()
 
 	while read dest src; do
 	    echo "Tickle TCP connection $src $dest"
-	    ctdb tickle $src $dest >/dev/null 2>&1 || _failed=true
+	    $CTDB tickle $src $dest >/dev/null 2>&1 || _failed=true
 	    echo "Tickle TCP connection $dest $src"
-	    ctdb tickle $dest $src >/dev/null 2>&1 || _failed=true
+	    $CTDB tickle $dest $src >/dev/null 2>&1 || _failed=true
 	done
 
 	if $_failed ; then
@@ -942,7 +942,7 @@ ctdb_replay_monitor_status ()
 {
     echo "Replaying previous status for this script due to reconfigure..."
     # Leading separator ('|') is missing in some versions...
-    _out=$(ctdb scriptstatus -X | grep -E "^\|?monitor\|${script_name}\|")
+    _out=$($CTDB scriptstatus -X | grep -E "^\|?monitor\|${script_name}\|")
     # Output looks like this:
     # |monitor|60.nfs|1|ERROR|1314764004.030861|1314764004.035514|foo bar|
     # This is the cheapest way of getting fields in the middle.
@@ -1211,7 +1211,7 @@ update_tickles ()
 	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 and port as ss filters
 	_ip_filter=""
@@ -1236,7 +1236,7 @@ update_tickles ()
 	# Record our current tickles in a temporary file
 	_my_tickles="${tickledir}/${_port}.tickles.$$"
 	for _i in $_ips ; do
-		ctdb -X gettickles $_i $_port |
+		$CTDB -X gettickles $_i $_port |
 		awk -F'|' 'NR > 1 { printf "%s:%s %s:%s\n", $2, $3, $4, $5 }'
 	done |
 	sort >"$_my_tickles"
@@ -1244,13 +1244,13 @@ update_tickles ()
 	# Add tickles for connections that we haven't already got tickles for
 	comm -23 "$_my_connections" "$_my_tickles" |
 	while read _src _dst ; do
-		ctdb addtickle $_src $_dst
+		$CTDB addtickle $_src $_dst
 	done
 
 	# Remove tickles for connections that are no longer there
 	comm -13 "$_my_connections" "$_my_tickles" |
 	while read _src _dst ; do
-		ctdb deltickle $_src $_dst
+		$CTDB deltickle $_src $_dst
 	done
 
 	rm -f "$_my_connections" "$_my_tickles"
-- 
2.5.5


From 6462fb4afa841d2383ef7fb0040b944dd83a6fcd Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 7 Jun 2016 07:44:53 +0000
Subject: [PATCH 06/16] ctdb: use properly configured ctdb in ctdbd_wrapper

This makes ctdbd_wrapper usable in non-standard installs.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/ctdbd_wrapper | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index 192b20d..a58d5ca 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -234,7 +234,7 @@ start()
 		return 1
 	    fi
 
-	    if ctdb runstate first_recovery startup running >/dev/null 2>&1 ; then
+	    if $CTDB runstate first_recovery startup running >/dev/null 2>&1 ; then
 		return 0
 	    fi
 	fi
@@ -256,7 +256,7 @@ stop()
 	return 0
     fi
 
-    ctdb shutdown
+    $CTDB shutdown
 
     # Wait for remaining CTDB processes to exit...
     _timeout=${CTDB_SHUTDOWN_TIMEOUT:-30}
-- 
2.5.5


From ff2e09a4446c5ade9cef815b86e3474136e455d4 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 13:21:56 +0200
Subject: [PATCH 07/16] ctdb: use properly configured ctdb in 00.ctdb

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/00.ctdb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb
index 3bc20d7..bb150ac 100755
--- a/ctdb/config/events.d/00.ctdb
+++ b/ctdb/config/events.d/00.ctdb
@@ -107,7 +107,7 @@ set_ctdb_variables ()
     while read v; do
 	varname="${v#CTDB_SET_}"
 	value=$(eval echo "\$$v")
-	if ctdb setvar $varname $value ; then
+	if $CTDB setvar $varname $value ; then
 	    echo "Set $varname to $value"
 	else
 	    echo "Invalid configuration: CTDB_SET_${varname}=${value}"
@@ -140,7 +140,7 @@ case "$1" in
 	;;
 
     startup)
-	ctdb attach ctdb.tdb persistent
+	$CTDB attach ctdb.tdb persistent
 	;;
 
     *)
-- 
2.5.5


From fe8e90f36a9e81bed9adb9a76cdd55d41fcc0c7f Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 13:22:24 +0200
Subject: [PATCH 08/16] ctdb: use properly configured ctdb in 01.reclock

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/01.reclock | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/config/events.d/01.reclock b/ctdb/config/events.d/01.reclock
index e2d4d12..da37cf8 100755
--- a/ctdb/config/events.d/01.reclock
+++ b/ctdb/config/events.d/01.reclock
@@ -41,7 +41,7 @@ case "$1" in
 	    echo "Reclock file \"$CTDB_RECOVERY_LOCK\" can not be accessed. Shutting down."
 	    df
 	    sleep 1
-	    ctdb shutdown
+	    $CTDB shutdown
 	fi
 
 	ctdb_check_counter "error" -gt 3
-- 
2.5.5


From bc052b0f2e5ae003a1a51977c091e56b32aab216 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 13:22:44 +0200
Subject: [PATCH 09/16] ctdb: use properly configured ctdb in 10.external

---
 ctdb/config/events.d/10.external | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ctdb/config/events.d/10.external b/ctdb/config/events.d/10.external
index 3fcb0e1..40f4680 100644
--- a/ctdb/config/events.d/10.external
+++ b/ctdb/config/events.d/10.external
@@ -28,12 +28,12 @@ takeover_assigned_ips ()
 {
     ctdb_get_pnn
 
-    ctdb -X ip |
+    $CTDB -X ip |
     awk -F'|' '{print $2}' |
     while read ip ; do
 	if [ -n "$(ip_maskbits_iface $ip)" ] ; then
 	    echo "Assigning $ip to this node ($pnn)"
-	    ctdb moveip "$ip" "$pnn"
+	    $CTDB moveip "$ip" "$pnn"
 	fi
     done
 }
-- 
2.5.5


From c2e85a490505f948f91a7398e8a5d85eaed35d11 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 13:23:07 +0200
Subject: [PATCH 10/16] ctdb: use properly configured ctdb in 13.per_ip_routing

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/13.per_ip_routing | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ctdb/config/events.d/13.per_ip_routing b/ctdb/config/events.d/13.per_ip_routing
index 56dfc34..cfcd484 100755
--- a/ctdb/config/events.d/13.per_ip_routing
+++ b/ctdb/config/events.d/13.per_ip_routing
@@ -292,7 +292,7 @@ flush_rules_and_routes ()
 # routes.
 add_missing_routes ()
 {
-    ctdb ip -v -X | {
+    $CTDB ip -v -X | {
 	read _x # skip header line
 
 	# Read the rest of the lines.  We're only interested in the
@@ -319,7 +319,7 @@ add_missing_routes ()
 remove_bogus_routes ()
 {
     # Get a IPs current hosted by this node, each anchored with '@'.
-    _ips=$(ctdb ip -v -X | awk -F'|' 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
+    _ips=$($CTDB ip -v -X | awk -F'|' 'NR > 1 && $4 != "" {printf "@%s@\n", $2}')
 
     ip rule show |
     while read _p _x _i _x _t ; do
@@ -382,7 +382,7 @@ case "$1" in
 	# flush our route cache
 	set_proc sys/net/ipv4/route/flush 1
 
-	ctdb gratiousarp "$ip" "$iface"
+	$CTDB gratiousarp "$ip" "$iface"
 	;;
 
     updateip)
@@ -397,7 +397,7 @@ case "$1" in
 	# flush our route cache
 	set_proc sys/net/ipv4/route/flush 1
 
-	ctdb gratiousarp "$ip" "$niface"
+	$CTDB gratiousarp "$ip" "$niface"
 	tickle_tcp_connections "$ip"
 	;;
 
-- 
2.5.5


From 2eac32f7fdd15551385b1ea3011676e89f6c234c Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 12:37:00 +0200
Subject: [PATCH 11/16] ctdb: use properly configured ctdb in 10.interfaces

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/10.interface | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ctdb/config/events.d/10.interface b/ctdb/config/events.d/10.interface
index bdb9443..204f4c6 100755
--- a/ctdb/config/events.d/10.interface
+++ b/ctdb/config/events.d/10.interface
@@ -33,7 +33,7 @@ get_all_interfaces ()
 
     # Get the interfaces for which CTDB has public IPs configured.
     # That is, for all but the 1st line, get the 1st field.
-    ctdb_ifaces=$(ctdb -X ifaces | sed -e '1d' -e 's@^|@@' -e 's@|.*@@')
+    ctdb_ifaces=$($CTDB -X ifaces | sed -e '1d' -e 's@^|@@' -e 's@|.*@@')
 
     # Add $ctdb_interfaces and uniquify
     all_interfaces=$(echo $all_interfaces $ctdb_ifaces | tr ' ' '\n' | sort -u)
@@ -52,10 +52,10 @@ monitor_interfaces()
 	for _iface in $all_interfaces ; do
 		if interface_monitor "$_iface" ; then
 			up_interfaces_found=true
-			ctdb setifacelink "$_iface" up >/dev/null 2>&1
+			$CTDB setifacelink "$_iface" up >/dev/null 2>&1
 		else
 			down_interfaces_found=true
-			ctdb setifacelink "$_iface" down >/dev/null 2>&1
+			$CTDB setifacelink "$_iface" down >/dev/null 2>&1
 		fi
 	done
 
@@ -233,7 +233,7 @@ case "$1" in
 	flush_route_cache
 
 	# propagate the new mac address
-	ctdb gratiousarp $ip $niface
+	$CTDB gratiousarp $ip $niface
 
 	# tickle all existing connections, so that dropped packets
 	# are retransmited and the tcp streams work
-- 
2.5.5


From f86f7be8c067ef4ad8c19ada58aaa76ac4fc8e22 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 12:44:28 +0200
Subject: [PATCH 12/16] ctdb: use properly configured ctdb in 70.iscsi

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/70.iscsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi
index 33b71c4..9e75214 100755
--- a/ctdb/config/events.d/70.iscsi
+++ b/ctdb/config/events.d/70.iscsi
@@ -22,7 +22,7 @@ is_ctdb_managed_service || exit 0
 
 case "$1" in
     ipreallocated)
-	all_ips=$(ctdb -X ip | tail -n +2)
+	all_ips=$($CTDB -X ip | tail -n +2)
 
 	# Block the iSCSI port.  Only block for the address families
 	# we have configured.  This copes with, for example, ip6tables
-- 
2.5.5


From bc9f5e52a886cbe07263e5ab821d7ff55c4b8e93 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 13:04:48 +0200
Subject: [PATCH 13/16] ctdb: use properly configured ctdb in 91.lvs

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/91.lvs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/config/events.d/91.lvs b/ctdb/config/events.d/91.lvs
index 141f964..434bd2b 100755
--- a/ctdb/config/events.d/91.lvs
+++ b/ctdb/config/events.d/91.lvs
@@ -109,7 +109,7 @@ ipreallocated)
 	ipvsadm -a -t "$CTDB_LVS_PUBLIC_IP" -r 127.0.0.1
 	ipvsadm -a -u "$CTDB_LVS_PUBLIC_IP" -r 127.0.0.1
 
-	ctdb gratiousarp \
+	$CTDB gratiousarp \
 	     "$CTDB_LVS_PUBLIC_IP" "$CTDB_LVS_PUBLIC_IFACE" >/dev/null 2>&1
 
 	flush_route_cache
-- 
2.5.5


From bb9c386681d6f6851112b199f5283853460db8e7 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 13:05:03 +0200
Subject: [PATCH 14/16] ctdb: use properly configured ctdb in 99.timeout

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/events.d/99.timeout | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/config/events.d/99.timeout b/ctdb/config/events.d/99.timeout
index 2a6495a..c18475f 100755
--- a/ctdb/config/events.d/99.timeout
+++ b/ctdb/config/events.d/99.timeout
@@ -14,7 +14,7 @@ loadconfig ctdb
 
 case "$1" in
     monitor)
-	TIMEOUT=$(ctdb getvar EventScriptTimeout | awk '{print $3}')
+	TIMEOUT=$($CTDB getvar EventScriptTimeout | awk '{print $3}')
 	echo "sleeping for $((TIMEOUT * 2)) seconds..."
 	sleep $((TIMEOUT * 2))
 	;;
-- 
2.5.5


From bb301c25b68a5cd3d3125f109d1f133cbe76df56 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 12:28:56 +0200
Subject: [PATCH 15/16] ctdb: use properly configured ctdb in statd-callout

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/statd-callout | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout
index a923d8a..1cbe653 100755
--- a/ctdb/config/statd-callout
+++ b/ctdb/config/statd-callout
@@ -49,7 +49,7 @@ case "$1" in
 	cip="$2"
 	ctdb_get_pnn
 	date=$(date '+%s')
-	ctdb ip -X |
+	$CTDB ip -X |
 	tail -n +2 |
 	while IFS="|" read x sip node x ; do
 	    [ "$node" = "$pnn" ] || continue # not us
@@ -63,7 +63,7 @@ case "$1" in
 	# so we must add it to all the IPs that we serve
 	cip="$2"
 	ctdb_get_pnn
-	ctdb ip -X |
+	$CTDB ip -X |
 	tail -n +2 |
 	while IFS="|" read x sip node x ; do
 	    [ "$node" = "$pnn" ] || continue # not us
@@ -81,12 +81,12 @@ case "$1" in
 	# Filter out lines for any IP addresses that are not currently
 	# hosted public IP addresses.
 	ctdb_get_pnn
-	ctdb_ips=$(ctdb ip | tail -n +2)
+	ctdb_ips=$($CTDB ip | tail -n +2)
 	sed_expr=$(echo "$ctdb_ips" |
 	    awk -v pnn=$pnn 'pnn == $2 { \
                 ip = $1; gsub(/\./, "\\.", ip); \
                 printf "/statd-state@%s@/p\n", ip }')
-        if cat $files | sed -n "$sed_expr" | ctdb ptrans "ctdb.tdb" ; then
+        if cat $files | sed -n "$sed_expr" | $CTDB ptrans "ctdb.tdb" ; then
             rm $files
 	fi
         ;;
@@ -159,13 +159,13 @@ case "$1" in
 	# Construct a sed expression to take catdb output and produce pairs of:
 	#   server-IP client-IP
 	# but only for the server-IPs that are hosted on this node.
-	ctdb_all_ips=$(ctdb ip all | tail -n +2)
+	ctdb_all_ips=$($CTDB ip all | tail -n +2)
 	sed_expr=$(echo "$ctdb_all_ips" |
 	    awk -v pnn=$pnn 'pnn == $2 { \
                 ip = $1; gsub(/\./, "\\.", ip); \
                 printf "s/^key.*=.*statd-state@\\(%s\\)@\\([^\"]*\\).*/\\1 \\2/p\n", ip }')
 
-	statd_state=$(ctdb catdb ctdb.tdb | sed -n "$sed_expr" | sort)
+	statd_state=$($CTDB catdb ctdb.tdb | sed -n "$sed_expr" | sort)
 	[ -n "$statd_state" ] || exit 0
 
 	smnotify="${CTDB_HELPER_BINDIR}/smnotify"
@@ -195,7 +195,7 @@ case "$1" in
 		"$smnotify" --client=$cip --ip=$sip --server=$NFS_HOSTNAME --stateval=$stateval
 	    done
 
-	    echo "$items" | ctdb ptrans "ctdb.tdb"
+	    echo "$items" | $CTDB ptrans "ctdb.tdb"
 	}
 
 	# Remove any stale touch files (i.e. for IPs not currently
-- 
2.5.5


From bc66255de96b5d03723b420dd35f3912dc210289 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 8 Jun 2016 12:32:04 +0200
Subject: [PATCH 16/16] ctdb: use properly configured ctdb in
 debug-hung-script.sh

Signed-off-by: Michael Adam <obnox at samba.org>
---
 ctdb/config/debug-hung-script.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ctdb/config/debug-hung-script.sh b/ctdb/config/debug-hung-script.sh
index 9bde684..cef004b 100755
--- a/ctdb/config/debug-hung-script.sh
+++ b/ctdb/config/debug-hung-script.sh
@@ -47,7 +47,7 @@ fi
 
     if [ "$2" != "init" ] ; then
 	echo "---- ctdb scriptstatus ${2}: ----"
-	ctdb scriptstatus "$2"
+	$CTDB scriptstatus "$2"
     fi
 
     echo "===== End of hung script debug for PID=\"$1\", event=\"$2\" ====="
-- 
2.5.5

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160608/945588f7/signature.sig>


More information about the samba-technical mailing list