From 09b5e4978ab1df09f47156147848a6bf099ea665 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Sat, 18 Apr 2015 22:00:49 +1000 Subject: [PATCH] ctdb-scripts: Changed uses of "ctdb xpnn" to ctdb_get_pnn() "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 Reviewed-by: Amitay Isaacs --- ctdb/config/events.d/00.ctdb | 3 ++- ctdb/config/events.d/70.iscsi | 7 +++---- ctdb/config/statd-callout | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ctdb/config/events.d/00.ctdb b/ctdb/config/events.d/00.ctdb index 07bc7a78130..0688411dd90 100755 --- a/ctdb/config/events.d/00.ctdb +++ b/ctdb/config/events.d/00.ctdb @@ -103,7 +103,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" diff --git a/ctdb/config/events.d/70.iscsi b/ctdb/config/events.d/70.iscsi index 42d261b8f02..33b71c42ada 100755 --- a/ctdb/config/events.d/70.iscsi +++ b/ctdb/config/events.d/70.iscsi @@ -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 diff --git a/ctdb/config/statd-callout b/ctdb/config/statd-callout index 4a331aca2cf..347af41a7cd 100755 --- a/ctdb/config/statd-callout +++ b/ctdb/config/statd-callout @@ -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 -- 2.47.3