scripts: Changed uses of "ctdb xpnn" to ctdb_get_pnn()
authorMartin Schwenke <martin@meltin.net>
Sat, 18 Apr 2015 12:00:49 +0000 (22:00 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 24 Feb 2016 10:44:27 +0000 (21:44 +1100)
"ctdb xpnn" does not work when sysctl net.ipv4.ip_nonlocal_bind=1,
since it determines the node by attempting to bind to each addres in
the nodes file.  The solution is to not use "ctdb xpnn".  After the
initial call, ctdb_get_pnn() will be more efficient that "ctdb xpnn".

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(Imported from commit 09b5e4978ab1df09f47156147848a6bf099ea665)

config/events.d/00.ctdb
config/events.d/70.iscsi
config/statd-callout

index ec181757cf3b90639bd8e867616ea2aaef0f1cc6..cb4b7f70f37d77c70e9b20981457f01702079fa6 100755 (executable)
@@ -102,7 +102,8 @@ EOF
 update_config_from_tdb() {
 
     # Pull optional ctdb configuration data out of config.tdb
-    _key="public_addresses:node#$(ctdb -t 1 xpnn|sed -e 's/.*://')"
+    ctdb_get_pnn
+    _key="public_addresses:node#${pnn}"
     _t="$service_state_dir/public_addresses"
     rm -f "$_t"
 
index 42d261b8f022b98c81ac6c5cd60d65097005e2aa..33b71c42ada97e0da27ab64dc3338af7f5ef419f 100755 (executable)
@@ -47,15 +47,14 @@ EOF
        # Stop iSCSI daemon
        killall -9 tgtd >/dev/null 2>/dev/null
 
-       # What node is this?
-       this_node=$(ctdb xpnn | sed -e 's@PNN:@@')
-       [ -n "$this_node" ] || die "Failed to get node pnn"
+       ctdb_get_pnn
+       [ -n "$pnn" ] || die "Failed to get node pnn"
 
        # Start iSCSI daemon
        tgtd >/dev/null 2>&1
 
        # Run a script for each currently hosted public IP address
-       ips=$(echo "$all_ips" | awk -F'|' -v pnn=$this_node '$3 == pnn {print $2}')
+       ips=$(echo "$all_ips" | awk -F'|' -v pnn=$pnn '$3 == pnn {print $2}')
        for ip in $ips ; do
            script="${CTDB_START_ISCSI_SCRIPTS}/${ip}.sh"
            if [ -x "$script" ] ; then
index 4a331aca2cf267bebe533f58100eb9b80d45f06d..347af41a7cd5fdc9a84c3d9f95f1abca068ed07f 100755 (executable)
@@ -47,7 +47,7 @@ case "$1" in
        # statd does not tell us to which IP the client connected so
        # we must add it to all the IPs that we serve
        cip="$2"
-       pnn=$(ctdb xpnn | sed -e 's/.*://')
+       ctdb_get_pnn
        date=$(date '+%s')
        ctdb ip -X |
        tail -n +2 |
@@ -62,7 +62,7 @@ case "$1" in
        # statd does not tell us from which IP the client disconnected
        # so we must add it to all the IPs that we serve
        cip="$2"
-       pnn=$(ctdb xpnn | sed -e 's/.*://')
+       ctdb_get_pnn
        ctdb ip -X |
        tail -n +2 |
        while IFS="|" read x sip node x ; do
@@ -80,7 +80,7 @@ case "$1" in
        fi
        # Filter out lines for any IP addresses that are not currently
        # hosted public IP addresses.
-       pnn=$(ctdb xpnn | sed -e 's/.*://')
+       ctdb_get_pnn
        ctdb_ips=$(ctdb ip | tail -n +2)
        sed_expr=$(echo "$ctdb_ips" |
            awk -v pnn=$pnn 'pnn == $2 { \
@@ -156,7 +156,7 @@ case "$1" in
        # probability that the client will accept the statd notify packet and
        # not just ignore it.
        # For all IPs we serve, collect info and push to the config database
-       pnn=$(ctdb xpnn | sed -e 's/.*://')
+       ctdb_get_pnn
 
        # Construct a sed expression to take catdb output and produce pairs of:
        #   server-IP client-IP