looping forever on older versions of CTDB.
Signed-off-by: Martin Schwenke <martin@meltin.net>
return $ret
}
+sanity_check_ips ()
+{
+ local ips="$1" # Output of "ctdb ip -n all"
+
+ echo "Sanity checking IPs..."
+
+ local x ipp prev
+ prev=""
+ while read x ipp ; do
+ [ "$ipp" = "-1" ] && break
+ if [ -n "$prev" -a "$ipp" != "$prev" ] ; then
+ echo "OK"
+ return 0
+ fi
+ prev="$ipp"
+ done <<<"$ips"
+
+ echo "BAD: a node was -1 or IPs are only assigned to one node"
+ echo "Are you running an old version of CTDB?"
+ return 1
+}
+
#######################################
# Wait until either timeout expires or command succeeds. The command
echo "Getting list of public IPs..."
try_command_on_node -v 0 "$CTDB ip -n all | sed -e '1d'"
+sanity_check_ips "$out"
+
# Select an IP/node to move.
num_ips=$(echo "$out" | wc -l)
num_to_move=$(($RANDOM % $num_ips))