Ansibly the network sanity check
Replace the network sanity check bash logic for the network_sanity_check role. This is the last step of replacing the setup_host bash function, thus removing also the function altogether. Change-Id: I8814cf284e572dda66455eea7a10f61037979a9b
This commit is contained in:
parent
f5dccd60c2
commit
4d7b92ca16
|
@ -557,8 +557,6 @@ EOF
|
|||
echo "... this takes a few seconds (logs at logs/devstack-gate-setup-host.txt.gz)"
|
||||
$ANSIBLE_PLAYBOOK -f 5 -i "$WORKSPACE/inventory" "$WORKSPACE/devstack-gate/playbooks/setup_host.yaml" \
|
||||
&> "$WORKSPACE/logs/devstack-gate-setup-host.txt"
|
||||
$ANSIBLE all -f 5 -i "$WORKSPACE/inventory" -m shell \
|
||||
-a "$(run_command setup_host)" &>> "$WORKSPACE/logs/devstack-gate-setup-host.txt"
|
||||
|
||||
if [ -n "$DEVSTACK_GATE_GRENADE" ]; then
|
||||
start=$(date +%s)
|
||||
|
|
39
functions.sh
39
functions.sh
|
@ -117,32 +117,6 @@ function _http_check {
|
|||
done
|
||||
}
|
||||
|
||||
# do a few network tests to baseline how bad we are
|
||||
function network_sanity_check {
|
||||
echo "Performing network sanity check..."
|
||||
PIP_CONFIG_FILE=/etc/pip.conf
|
||||
if [[ -f $PIP_CONFIG_FILE ]]; then
|
||||
line=$(cat $PIP_CONFIG_FILE|grep --max-count 1 index-url)
|
||||
pypi_url=${line#*=}
|
||||
pypi_host=$(echo $pypi_url|grep -Po '.*?//\K.*?(?=/)')
|
||||
|
||||
_ping_check $pypi_host
|
||||
_http_check $pypi_url
|
||||
fi
|
||||
|
||||
if [[ -f /etc/nodepool/provider ]]; then
|
||||
# AFS ubuntu mirror
|
||||
source /etc/nodepool/provider
|
||||
if [[ -n "$NODEPOOL_MIRROR_HOST" || ( -n "$NODEPOOL_REGION" && -n "$NODEPOOL_CLOUD" ) ]]; then
|
||||
NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org}
|
||||
NODEPOOL_MIRROR_HOST=$(echo $NODEPOOL_MIRROR_HOST|tr '[:upper:]' '[:lower:]')
|
||||
|
||||
_ping_check $NODEPOOL_MIRROR_HOST
|
||||
_http_check http://$NODEPOOL_MIRROR_HOST/ubuntu/dists/trusty/Release
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# create the start timer for when the job began
|
||||
function start_timer {
|
||||
# first make sure the time is right, so we don't go into crazy land
|
||||
|
@ -571,19 +545,6 @@ function setup_workspace {
|
|||
$xtrace
|
||||
}
|
||||
|
||||
function setup_host {
|
||||
# Enabled detailed logging, since output of this function is redirected
|
||||
local xtrace=$(set +o | grep xtrace)
|
||||
set -o xtrace
|
||||
|
||||
# perform network sanity check so that we can characterize the
|
||||
# state of the world
|
||||
network_sanity_check
|
||||
|
||||
# Disable detailed logging as we return to the main script
|
||||
$xtrace
|
||||
}
|
||||
|
||||
function archive_test_artifact {
|
||||
local filename=$1
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
---
|
||||
BASE: "{{ lookup('env', 'BASE')|default('/opt/stack', true) }}"
|
||||
CI_USER: "{{ lookup('env', 'CI_USER')|default(ansible_user_id, true) }}"
|
||||
PING_TIMES: 20
|
||||
HTTP_TIMES: 10
|
||||
PIP_CONFIG_FILE: "{{ lookup('env', 'PIP_CONFIG_FILE')|default('/etc/pip.conf', true) }}"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
- name: Perform HTTP check
|
||||
uri: url={{ url }}
|
||||
register: uri_result
|
||||
until: uri_result['status'] == 200
|
||||
retries: "{{ HTTP_TIMES }}"
|
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: Get status of file PIP_CONFIG_FILE
|
||||
stat: path={{ PIP_CONFIG_FILE }}
|
||||
register: st
|
||||
- block:
|
||||
- name: Set pypi_url variable
|
||||
set_fact: pypi_url={{ lookup('ini', 'index-url section=global file=' + PIP_CONFIG_FILE) }}
|
||||
- name: Set pypi_host variable
|
||||
set_fact: pypi_host={{ pypi_url.split('/')[2] }}
|
||||
- include: ping_check.yaml host={{ pypi_host }}
|
||||
- include: http_check.yaml url={{ pypi_url }}
|
||||
when: st.stat.exists
|
||||
- name: Get NODEPOOL_MIRROR_HOST from /etc/nodepool/provider
|
||||
shell: grep NODEPOOL_MIRROR_HOST /etc/nodepool/provider | cut -d "=" -f2
|
||||
register: grep_mirror_host
|
||||
changed_when: False
|
||||
- name: Get NODEPOOL_REGION from /etc/nodepool/provider
|
||||
shell: grep NODEPOOL_REGION /etc/nodepool/provider | cut -d "=" -f2
|
||||
register: grep_region
|
||||
changed_when: False
|
||||
- name: Get NODEPOOL_CLOUD from /etc/nodepool/provider
|
||||
shell: grep NODEPOOL_CLOUD /etc/nodepool/provider | cut -d "=" -f2
|
||||
register: grep_cloud
|
||||
changed_when: False
|
||||
- name: Build NODEPOOL_MIRROR_HOST variable with region and cloud if undefined
|
||||
set_fact: NODEPOOL_MIRROR_HOST={{ grep_mirror_host.stdout|default("mirror." + grep_region.stdout|lower + "." + grep_cloud.stdout + ".openstack.org", true) }}
|
||||
- include: ping_check.yaml host={{ NODEPOOL_MIRROR_HOST }}
|
||||
- include: http_check.yaml url=http://{{ NODEPOOL_MIRROR_HOST }}/ubuntu/dists/trusty/Release
|
|
@ -0,0 +1,3 @@
|
|||
- name: Perform ping check
|
||||
command: ping -c {{ PING_TIMES }} {{ host }}
|
||||
changed_when: False
|
|
@ -11,3 +11,4 @@
|
|||
- setup_stack_user
|
||||
- setup_tempest_user
|
||||
- copy_mirror_config
|
||||
- network_sanity_check
|
||||
|
|
Loading…
Reference in New Issue