[SCM] CTDB repository - branch master updated - ctdb-1.10-214-g66e8979

Ronnie Sahlberg sahlberg at samba.org
Tue Jun 7 22:24:24 MDT 2011


The branch, master has been updated
       via  66e89797c7866d207a5bbf1836f52d70dba7cea6 (commit)
       via  d60592cf99999f10344a05ef0571fb300bb9d97c (commit)
       via  74e69a564bac653dadfffe8b08145b9b3be16e61 (commit)
       via  e1788f25fde3d1f26bf4831a331741aa280f6fbc (commit)
       via  ca80adda7517b43147ef30156ae34c66b29fa2bd (commit)
       via  74715e6ec7b67c6f0e863aa51c87279758d6bf91 (commit)
       via  793febaebd3d484ddfbbcb47aaa0cdf3cfc1a00d (commit)
      from  2266586c1839af032622be54dc7f71e39d2bd9ef (commit)

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


- Log -----------------------------------------------------------------
commit 66e89797c7866d207a5bbf1836f52d70dba7cea6
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 15:33:12 2011 +1000

    onnode: fix natgwlist nodespec
    
    This hasn't worked for a while if ever.
    
    We treat this case specially because the output has 2 works on the 1st
    line.  We also handle the error case where /etc/ctdb_natgw_nodes
    exists but none of the other $NATGW_* configuration is done.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit d60592cf99999f10344a05ef0571fb300bb9d97c
Author: Martin Schwenke <martin at meltin.net>
Date:   Mon May 23 15:24:52 2011 +1000

    onnode: fix get_nodes_with_status()
    
    Setting IFS and looping though items with colons in them doesn't work.
    Change this to read through the output line by line.  The header line
    needs to be thrown away by throwing away everything up to the 1st
    newline.
    
    Keep stderr from the "ctdb status" command, otherwise debugging is
    impossible.
    
    On error, append any output from ctdb to onnode's error message.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 74e69a564bac653dadfffe8b08145b9b3be16e61
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 17 14:26:55 2011 +1000

    onnode: Remove an unnecessary comment.
    
    The comment about $CTDB_NODES_SOCKETS is meaningless.  The code ti
    refers to works just find with $CTDB_NODES_SOCKETS.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit e1788f25fde3d1f26bf4831a331741aa280f6fbc
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 17 14:24:30 2011 +1000

    onnode: Future-proof get_nodes_with_status().
    
    The current code requires knowledge of the number of status bits
    output by "ctdb status -Y".
    
    This changes the code to be completely general.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit ca80adda7517b43147ef30156ae34c66b29fa2bd
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 17 13:25:08 2011 +1000

    onnode: Exit with error for unknown command-line flags.
    
    Use of "local" was masking errors in command-line processing.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 74715e6ec7b67c6f0e863aa51c87279758d6bf91
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 17 13:20:51 2011 +1000

    onnode: Be defensive when listing IPs of nodes with designated status.
    
    The current version gives the last item left after stripping the known
    fields.  If an insufficent number of status fields is stripped then
    this would return a residual status field value, which turned out to
    be a valid IP address for localhost...  so no error occurs.
    
    This change means that the node number is stripped and any residual
    status field value will stay appended, causing an error the first time
    this command is tested.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

commit 793febaebd3d484ddfbbcb47aaa0cdf3cfc1a00d
Author: Martin Schwenke <martin at meltin.net>
Date:   Tue May 17 13:18:11 2011 +1000

    onnode - Fix long standing bug in onnode healthy/ok/connected/con.
    
    When the output of "ctdb status -Y" changed to add an extra status
    column we didn't fix onnode.
    
    This adds a match for the extra column.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>

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

Summary of changes:
 tools/onnode |   93 +++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 57 insertions(+), 36 deletions(-)


Changeset truncated at 500 lines:

diff --git a/tools/onnode b/tools/onnode
index fa61b47..804ab09 100755
--- a/tools/onnode
+++ b/tools/onnode
@@ -70,7 +70,9 @@ parse_options ()
     # $POSIXLY_CORRECT means that the command passed to onnode can
     # take options and getopt won't reorder things to make them
     # options ot onnode.
-    local temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqv" -l help -- "$@")
+    local temp
+    # Not on the previous line - local returns 0!
+    temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqv" -l help -- "$@")
 
     [ $? != 0 ] && usage
 
@@ -136,44 +138,47 @@ get_nodes_with_status ()
     local all_nodes="$1"
     local status="$2"
 
-    local bits
-    case "$status" in
-	healthy)
-	    bits="0:0:0:0:0"
-	    ;;
-	connected)
-	    bits="0:[0-1]:[0-1]:[0-1]:[0-1]"
-	    ;;
-	*)
-	    invalid_nodespec
-    esac
-
     if [ -z "$ctdb_status_output" ] ; then
-	# FIXME: need to do something if $CTDB_NODES_SOCKETS is set.
-	ctdb_status_output=$(ctdb -Y status 2>/dev/null)
+	ctdb_status_output=$(ctdb -Y status 2>&1)
 	if [ $? -ne 0 ] ; then
 	    echo "${prog}: unable to get status of CTDB nodes" >&2
+	    echo "$ctdb_status_output" >&2
 	    exit 1
 	fi
-	ctdb_status_output="${ctdb_status_output#* }"
+	local nl="
+"
+	ctdb_status_output="${ctdb_status_output#*${nl}}"
     fi
 
-    local nodes=""
-    local i
-    for i in $ctdb_status_output ; do
-	# Try removing bits from end.
-	local t="${i%:${bits}:}"
-	if [ "$t" != "$i" ] ; then
-	    # Succeeded.  Get address.  NOTE: this is an optimisation.
-	    # It might be better to get the node number and then get
-	    # the nth node to get the address.  This would make things
-	    # more consistent if $ctdb_base/nodes actually contained
-	    # hostnames.
-	    nodes="${nodes} ${t##*:}"
-	fi
-    done
+    (
+	local i
+	IFS="${IFS}:"
+	while IFS="" read i ; do
+
+	    set -- $i # split line on colons
+	    shift     # line starts with : so 1st field is empty
+	    local pnn="$1" ; shift
+	    local ip="$1" ; shift
+
+	    case "$status" in
+		healthy)
+		    # If any bit is not 0, don't match this address.
+		    local s
+		    for s ; do
+			[ "$s" = "0" ] || continue 2
+		    done
+		    ;;
+		connected)
+		    # If disconnected bit is not 0, don't match this address.
+		    [ "$1" = "0" ] || continue
+		    ;;
+		*)
+		    invalid_nodespec
+	    esac
 
-    echo $nodes
+	    echo_nth "$pnn" $all_nodes
+	done <<<"$ctdb_status_output"
+    )
 }
 
 ctdb_props="" # cache
@@ -184,20 +189,36 @@ get_node_with_property ()
 
     local prop_node=""
     if [ "${ctdb_props##:${prop}:}" = "$ctdb_props" ] ; then
+	# Not in cache.
 	prop_node=$(ctdb "$prop" -Y 2>/dev/null)
-	# We only want the first line.
-	local nl="
-"
-	prop_node="${prop_node%%${nl}*}"
 	if [ $? -eq 0 ] ; then
-	    ctdb_props="${ctdb_props}${ctdb_props:+ }:${prop}:${prop_node}"
+	    if [ "$prop" = "natgwlist" ] ; then
+		prop_node="${prop_node%% *}" # 1st word
+		if [ "$prop_node" = "-1" ] ; then
+		    # This works around natgwlist returning 0 even
+		    # when there's no natgw.
+		    prop_node=""
+		fi
+	    else
+		# We only want the first line.
+		local nl="
+"
+		prop_node="${prop_node%%${nl}*}"
+	    fi
 	else
 	    prop_node=""
 	fi
+
+	if [ -n "$prop_node" ] ; then
+	    # Add to cache.
+	    ctdb_props="${ctdb_props}${ctdb_props:+ }:${prop}:${prop_node}"
+	fi
     else
+	# Get from cache.
 	prop_node="${ctdb_props##:${prop}:}"
 	prop_node="${prop_node%% *}"
     fi
+
     if [ -n "$prop_node" ] ; then
 	echo_nth "$prop_node" $all_nodes
     else


-- 
CTDB repository


More information about the samba-cvs mailing list