[PATCH] CTDB onnode improvements

Martin Schwenke martin at meltin.net
Thu Mar 1 09:07:00 UTC 2018


On Thu, 1 Mar 2018 18:33:55 +1100, Amitay Isaacs <amitay at gmail.com>
wrote:

> On Thu, Mar 1, 2018 at 11:59 AM, Martin Schwenke via samba-technical
> <samba-technical at lists.samba.org> wrote:
> > Move some test support out of CTDB's onnode command and into the testing
> > code, with a few cleanups along the way.
> >
> > Part of the motivation is to stop onnode from using CTDB_SOCKET, which
> > we are planning to change to a test-only option.
> >
> > Please review and maybe push...  
> 
> In the patch where ssh_local_daemon.sh is introduced,  change the
> following line to print the IP address of the node.
> 
>     echo "$0: Unable to find socket for node ${pnn}" >&2
> 
> We are trying to run a command on particular IP and pnn is fake (it's
> 1-based, rather than 0-based).
> 
> With this change, Reviewed-by: Amitay Isaacs <amitay at gmail.com>

Thanks for catching that.  Since the caller only ever passes an IP
address it makes sense to print that in any error message.

Given that the code was technically wrong, I actually squashed in this
little patch that still uses a variable called pnn in the code but makes
it correctly 0-based. I tested the change by running on the
command-line. I hope that's OK.

diff --git a/ctdb/tests/simple/scripts/ssh_local_daemons.sh b/ctdb/tests/simple/scripts/ssh_local_daemons.sh
index 0c35863ae0b..ecf5ee952f2 100755
--- a/ctdb/tests/simple/scripts/ssh_local_daemons.sh
+++ b/ctdb/tests/simple/scripts/ssh_local_daemons.sh
@@ -20,11 +20,12 @@ ip="$1"
 # Complete command is provide by onnode as a single argument
 command="$2"
 
-pnn=$(awk -v ip="$ip" '$1 == ip { print NR }' "$nodes")
+num=$(awk -v ip="$ip" '$1 == ip { print NR }' "$nodes")
+pnn=$((num - 1))
 
 # Determine the correct Unix domain socket
 export CTDB_SOCKET=""
-n=1
+n=0
 for s in $CTDB_NODES_SOCKETS ; do
        if [ $n -eq $pnn ] ; then
                CTDB_SOCKET="$s"
@@ -33,7 +34,7 @@ for s in $CTDB_NODES_SOCKETS ; do
        n=$((n + 1))
 done
 if [ -z "$CTDB_SOCKET" ] ; then
-       echo "$0: Unable to find socket for node ${pnn}" >&2
+       echo "$0: Unable to find socket for node ${ip}" >&2
        exit 1
 fi
 

Pushing now, along with my other stuff, and your pcp fix.

peace & happiness,
martin



More information about the samba-technical mailing list