[gate fix] Handle case where hostname ends in .1

I appears that some of the clouds the gate uses can
assign a '.1' address as the controller ip.  The algorithm
used to determine the controller ip doesn't take this
into account.

This change detects this case and tries to use the first
one that doesn't start with '172.' or '192.'

Change-Id: If27e4508eb7ca87581345e3c2d562af02ea25f60
Closes-Bug: 1657247
This commit is contained in:
Peter Stachowski 2017-01-17 20:39:49 +00:00
parent 4bbfa7ca55
commit 4daa7a9237

View File

@ -1271,7 +1271,7 @@ function cmd_kick_start() {
} }
function cmd_dsvm_gate_tests() { function cmd_dsvm_gate_tests() {
ACTUAL_HOSTNAME=$(hostname -I | sed 's/[0-9]*\.[0-9]*\.[0-9]*\.1\b//g' | sed 's/[0-9a-z][0-9a-z]*:.*:[0-9a-z][0-9a-z]*//g' | sed 's/ /\n/g' | sed '/^$/d' | sort -bu | head -1) ACTUAL_HOSTNAME=$(hostname -I | sed 's/[0-9a-z][0-9a-z]*:.*:[0-9a-z][0-9a-z]*//g' | sed 's/[0-9]*\.[0-9]*\.[0-9]*\.1\b//g' | sed 's/ /\n/g' | sed '/^$/d' | sort -bu | head -1)
local DATASTORE_TYPE=${1:-'mysql'} local DATASTORE_TYPE=${1:-'mysql'}
local TEST_GROUP=${2:-${DATASTORE_TYPE}} local TEST_GROUP=${2:-${DATASTORE_TYPE}}
@ -1283,14 +1283,21 @@ function cmd_dsvm_gate_tests() {
exclaim "Running cmd_dsvm_gate_tests ..." exclaim "Running cmd_dsvm_gate_tests ..."
# Sometimes in the gate the ACTUAL_HOSTNAME is blank - this code attempts to debug it # Sometimes in the gate the ACTUAL_HOSTNAME is blank - this code attempts to debug it
if [[ -z "${CONTROLLER_ID}" ]]; then if [[ -z "${CONTROLLER_IP}" ]]; then
echo "*** CONTROLLER_IP is blank, trying to determine actual hostname" echo "*** CONTROLLER_IP is blank, trying to determine actual hostname"
local hostname_part=$(hostname -I) local hostname_part=$(hostname -I)
echo "Hostname pass 1: $hostname_part" echo "Hostname pass 1: $hostname_part"
hostname_part=$(echo $hostname_part | sed 's/[0-9]*\.[0-9]*\.[0-9]*\.1\b//g')
echo "Hostname pass 2: $hostname_part"
hostname_part=$(echo $hostname_part | sed 's/[0-9a-z][0-9a-z]*:.*:[0-9a-z][0-9a-z]*//g') hostname_part=$(echo $hostname_part | sed 's/[0-9a-z][0-9a-z]*:.*:[0-9a-z][0-9a-z]*//g')
echo "Hostname pass 2: $hostname_part"
hostname_part_no_ip6=$hostname_part
hostname_part=$(echo $hostname_part | sed 's/[0-9]*\.[0-9]*\.[0-9]*\.1\b//g')
echo "Hostname pass 3: $hostname_part" echo "Hostname pass 3: $hostname_part"
if [[ -z "${hostname_part}" ]]; then
# This seems to occur when the actual hostname ends with '.1'
# If this happens, take the first one that doesn't start with '192' or '172'
hostname_part=$(echo $hostname_part_no_ip6 | sed 's/1[79]2\.[0-9]*\.[0-9]*\.1\b//g')
echo "Hostname pass 3a: $hostname_part"
fi
hostname_part=$(echo $hostname_part | sed 's/ /\n/g') hostname_part=$(echo $hostname_part | sed 's/ /\n/g')
echo "Hostname pass 4: $hostname_part" echo "Hostname pass 4: $hostname_part"
hostname_part=$(echo $hostname_part | sed '/^$/d') hostname_part=$(echo $hostname_part | sed '/^$/d')
@ -1299,7 +1306,8 @@ function cmd_dsvm_gate_tests() {
echo "Hostname pass 6: $hostname_part" echo "Hostname pass 6: $hostname_part"
hostname_part=$(echo $hostname_part | head -1) hostname_part=$(echo $hostname_part | head -1)
echo "Hostname pass 7: $hostname_part" echo "Hostname pass 7: $hostname_part"
echo "*** CONTROLLER_IP is blank, actual hostname test over" CONTROLLER_IP=$hostname_part
echo "*** CONTROLLER_IP was blank (CONTROLLER_IP now set to '$CONTROLLER_IP')"
fi fi
export REPORT_DIRECTORY=${REPORT_DIRECTORY:=$HOME/dsvm-report/} export REPORT_DIRECTORY=${REPORT_DIRECTORY:=$HOME/dsvm-report/}