[SCM] CTDB repository - branch 1.2 updated - ctdb-1.9.1-440-gbfffe06

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


The branch, 1.2 has been updated
       via  bfffe067a8152145ef54482dccb49529c6a4827f (commit)
       via  d7ab0958609264df36b7db5591d7013c0d9f95d2 (commit)
       via  8f75f620f97672ad9ee65cb8d9c10d1916413ffb (commit)
       via  9051032bc1bdb1d26902800409a248c44836da58 (commit)
       via  a9caac9eeed27d6d5efd22926a962a25d1a5ef7f (commit)
       via  19a41fdc40fada29046d102de34d6fbe0c7a3768 (commit)
       via  8df10dfdbd9b19514caadf236c34eadcb07419f7 (commit)
      from  ee5e90f5ad43be8e3b0b3f0aa00e6fc0be982099 (commit)

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


- Log -----------------------------------------------------------------
commit bfffe067a8152145ef54482dccb49529c6a4827f
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 d7ab0958609264df36b7db5591d7013c0d9f95d2
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 8f75f620f97672ad9ee65cb8d9c10d1916413ffb
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 9051032bc1bdb1d26902800409a248c44836da58
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 a9caac9eeed27d6d5efd22926a962a25d1a5ef7f
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 19a41fdc40fada29046d102de34d6fbe0c7a3768
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 8df10dfdbd9b19514caadf236c34eadcb07419f7
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