[SCM] CTDB repository - branch 2.5 updated - ctdb-2.5.3-21-gae3deb8

Amitay Isaacs amitay at samba.org
Tue May 27 20:43:05 MDT 2014


The branch, 2.5 has been updated
       via  ae3deb87ab5fefdc33437fa4eca2f7468c581957 (commit)
       via  d05e0796fb2165f00f576162659b05e48043e026 (commit)
       via  a675b0e58ee24e61b7d26644867f22a698351e70 (commit)
       via  797018463bda9d9919574b23016e4d259ceef0ec (commit)
      from  8a6f2fc686c14c713ede05c863662d4583ff3841 (commit)

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


- Log -----------------------------------------------------------------
commit ae3deb87ab5fefdc33437fa4eca2f7468c581957
Author: Martin Schwenke <martin at meltin.net>
Date:   Fri Mar 28 16:18:17 2014 +1100

    daemon: Move a ZERO_STRUCT() to a better place
    
    It might as well be near where it is used.  Add a comment explaining
    it.
    
    Also add/update comments at the top of the RELEASE_IP and TAKEOVER_IP
    loops to explain what is happening.
    
    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 May  5 06:20:39 CEST 2014 on sn-devel-104
    
    (Imported from commit cbd6beb469c63749d68e6fa52b101c19ee75314f)

commit d05e0796fb2165f00f576162659b05e48043e026
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Jan 16 14:48:39 2014 +1100

    eventscripts: Add check for invalid policy routing configuration
    
    The range
    CTDB_PER_IP_ROUTING_TABLE_ID_LOW..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH
    should not include 253-255.  Otherwise policy routing may overwrite
    the default system routing tables.
    
    Add some corresponding tests.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Pair-programmed-with: Amitay Isaacs <amitay at gmail.com>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit 151b02cd9e05b120cc88086cfa0be6eaad04f736)

commit a675b0e58ee24e61b7d26644867f22a698351e70
Author: Martin Schwenke <martin at meltin.net>
Date:   Wed Jan 15 14:16:52 2014 +1100

    eventscripts: Update comment in 11.routing
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit e09147b6a31371d46b269563b707313619616564)

commit 797018463bda9d9919574b23016e4d259ceef0ec
Author: Martin Schwenke <martin at meltin.net>
Date:   Thu Mar 27 16:31:54 2014 +1100

    eventscripts: Don't check if $iface is empty
    
    This is the loop variable.  It can't be empty, especially given the
    way the list is built.  This must have survived from an earlier
    version of the script.
    
    Given that there are whitespace changes associated with the above,
    clean-up the "virtio_net" avoidance check so that it reads less like
    line-noise.
    
    Signed-off-by: Martin Schwenke <martin at meltin.net>
    Reviewed-by: Amitay Isaacs <amitay at gmail.com>
    
    (Imported from commit be71a84565e9e7532a77c175732b764d1f42c1cd)

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

Summary of changes:
 config/events.d/10.interface                |   28 ++++++++++++++------------
 config/events.d/11.routing                  |   21 ++++++++++++-------
 config/events.d/13.per_ip_routing           |    5 ++++
 server/ctdb_takeover.c                      |   15 +++++++++++--
 tests/eventscripts/13.per_ip_routing.021.sh |   14 +++++++++++++
 tests/eventscripts/13.per_ip_routing.022.sh |   14 +++++++++++++
 6 files changed, 73 insertions(+), 24 deletions(-)
 create mode 100755 tests/eventscripts/13.per_ip_routing.021.sh
 create mode 100755 tests/eventscripts/13.per_ip_routing.022.sh


Changeset truncated at 500 lines:

diff --git a/config/events.d/10.interface b/config/events.d/10.interface
index f44c674..ab20c46 100755
--- a/config/events.d/10.interface
+++ b/config/events.d/10.interface
@@ -110,22 +110,24 @@ monitor_interfaces()
 		mark_up $iface
 		;;
 	    *)
-		[ -z "$iface" ] || {
-		    [ "$(basename $(readlink /sys/class/net/$iface/device/driver) 2>/dev/null)" = virtio_net ] ||
+		# Ignore virtio_net devices, assume they're always up
+		_driver_path="/sys/class/net/$iface/device/driver"
+		_driver=$(basename $(readlink "$_driver_path") 2>/dev/null)
+		[ "$_driver" = "virtio_net" ] && continue
+
+		ethtool $iface | grep -q 'Link detected: yes' || {
+		    # On some systems, this is not successful when a
+		    # cable is plugged but the interface has not been
+		    # brought up previously. Bring the interface up
+		    # and try again...
+		    ip link set $iface up
 		    ethtool $iface | grep -q 'Link detected: yes' || {
-			# On some systems, this is not successful when a
-			# cable is plugged but the interface has not been
-			# brought up previously. Bring the interface up and
-			# try again...
-			ip link set $iface up
-			ethtool $iface | grep -q 'Link detected: yes' || {
-			    echo "ERROR: No link on the public network interface $iface"
-			    mark_down $iface
-			    continue
-			}
+			echo "ERROR: No link on the public network interface $iface"
+			mark_down $iface
+			continue
 		    }
-		    mark_up $iface
 		}
+		mark_up $iface
 		;;
 	    esac
 
diff --git a/config/events.d/11.routing b/config/events.d/11.routing
index ccc60e7..2fe560f 100755
--- a/config/events.d/11.routing
+++ b/config/events.d/11.routing
@@ -1,15 +1,20 @@
 #!/bin/sh
-# script to add entries to the routing table after we have performed a
-# take ip event
-# (when we do a "releaseip" event and remove an ip address from an interface
-#  the kernel might automatically remove associated entries from
-#  the routing table. This is where we add them back)
+
+# Attempt to add a set of static routes.
+#
+# Do this in "ipreallocated" rather than just "startup" because some
+# of the routes might be missing because the corresponding interface
+# has not previously had any IPs assigned or IPs were previously
+# released and corresponding routes were dropped.
+#
+# Addition of some routes might fail, errors go to /dev/null.
+#
+# Routes to add are defined in $CTDB_BASE/static-routes. Syntax is:
 #
-# Routes to add are defined in /etc/ctdb/static-routes.
-# Syntax is :
 # IFACE NET/MASK GATEWAY
 #
-# Example
+# Example:
+#
 # bond1 10.3.3.0/24 10.0.0.1
 
 [ -n "$CTDB_BASE" ] || \
diff --git a/config/events.d/13.per_ip_routing b/config/events.d/13.per_ip_routing
index de153a6..ee83632 100755
--- a/config/events.d/13.per_ip_routing
+++ b/config/events.d/13.per_ip_routing
@@ -19,6 +19,11 @@ table_id_prefix="ctdb."
 [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -lt "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] 2>/dev/null || \
     die "error: CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW] and/or CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] improperly configured"
 
+if [ "$CTDB_PER_IP_ROUTING_TABLE_ID_LOW" -le 253 -a \
+    255 -le "$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH" ] ; then
+    die "error: range CTDB_PER_IP_ROUTING_TABLE_ID_LOW[$CTDB_PER_IP_ROUTING_TABLE_ID_LOW]..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[$CTDB_PER_IP_ROUTING_TABLE_ID_HIGH] must not include 253-255"
+fi
+
 have_link_local_config ()
 {
     [ "$CTDB_PER_IP_ROUTING_CONF" = "__auto_link_local__" ]
diff --git a/server/ctdb_takeover.c b/server/ctdb_takeover.c
index 34afea5..f8a26f0 100644
--- a/server/ctdb_takeover.c
+++ b/server/ctdb_takeover.c
@@ -2695,8 +2695,6 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
 		return -1;
 	}
 
-	ZERO_STRUCT(ip);
-
 	/* Do the IP reassignment calculations */
 	ctdb_takeover_run_core(ctdb, ipflags, &all_ips, force_rebalance_nodes);
 
@@ -2720,6 +2718,14 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
 	async_data->fail_callback = takeover_run_fail_callback;
 	async_data->callback_data = takeover_data;
 
+	ZERO_STRUCT(ip); /* Avoid valgrind warnings for union */
+
+	/* Send a RELEASE_IP to all nodes that should not be hosting
+	 * each IP.  For each IP, all but one of these will be
+	 * redundant.  However, the redundant ones are used to tell
+	 * nodes which node should be hosting the IP so that commands
+	 * like "ctdb ip" can display a particular nodes idea of who
+	 * is hosting what. */
 	for (i=0;i<nodemap->num;i++) {
 		/* don't talk to unconnected nodes, but do talk to banned nodes */
 		if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
@@ -2774,7 +2780,10 @@ int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap,
 	talloc_free(async_data);
 
 
-	/* tell all nodes to get their own IPs */
+	/* For each IP, send a TAKOVER_IP to the node that should be
+	 * hosting it.  Many of these will often be redundant (since
+	 * the allocation won't have changed) but they can be useful
+	 * to recover from inconsistencies. */
 	async_data = talloc_zero(tmp_ctx, struct client_async_data);
 	CTDB_NO_MEMORY_FATAL(ctdb, async_data);
 
diff --git a/tests/eventscripts/13.per_ip_routing.021.sh b/tests/eventscripts/13.per_ip_routing.021.sh
new file mode 100755
index 0000000..609ecad
--- /dev/null
+++ b/tests/eventscripts/13.per_ip_routing.021.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "Invalid table ID range - includes system tables"
+
+setup_ctdb
+setup_ctdb_policy_routing
+
+CTDB_PER_IP_ROUTING_TABLE_ID_LOW=100
+CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=500
+
+required_result 1 "error: range CTDB_PER_IP_ROUTING_TABLE_ID_LOW[${CTDB_PER_IP_ROUTING_TABLE_ID_LOW}]..CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[${CTDB_PER_IP_ROUTING_TABLE_ID_HIGH}] must not include 253-255"
+simple_test_event "ipreallocated"
diff --git a/tests/eventscripts/13.per_ip_routing.022.sh b/tests/eventscripts/13.per_ip_routing.022.sh
new file mode 100755
index 0000000..28997e3
--- /dev/null
+++ b/tests/eventscripts/13.per_ip_routing.022.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+. "${TEST_SCRIPTS_DIR}/unit.sh"
+
+define_test "Invalid table ID range - reversed"
+
+setup_ctdb
+setup_ctdb_policy_routing
+
+CTDB_PER_IP_ROUTING_TABLE_ID_LOW=9000
+CTDB_PER_IP_ROUTING_TABLE_ID_HIGH=1000
+
+required_result 1 "error: CTDB_PER_IP_ROUTING_TABLE_ID_LOW[${CTDB_PER_IP_ROUTING_TABLE_ID_LOW}] and/or CTDB_PER_IP_ROUTING_TABLE_ID_HIGH[${CTDB_PER_IP_ROUTING_TABLE_ID_HIGH}] improperly configured"
+simple_test_event "ipreallocated"


-- 
CTDB repository


More information about the samba-cvs mailing list