Move to zuul v3 in project jobs

- move check container failure from post.yml to run.yml
- add binary related jobs
- use static kolla-ansible src dir, which is helpful for kolla project
  to use.
- generate correct /etc/hosts by using private ip address and hostname
- fix the wrong api interface in global.yml file

Partial-Bug: #1720601
Change-Id: Ibc20a6ae8c645ff82f3c14a6286073dffd4cfae2
(cherry picked from commit 3908934f70)
This commit is contained in:
Jeffrey Zhang 2017-10-01 23:21:38 +08:00
parent bd0aff594e
commit b2c0830006
12 changed files with 340 additions and 265 deletions

75
.zuul.yaml Normal file
View File

@ -0,0 +1,75 @@
- project:
name: openstack/kolla-ansible
check:
jobs:
- kolla-ansible-centos-source
- kolla-ansible-ubuntu-source
- kolla-ansible-oraclelinux-source
- job:
name: kolla-ansible-base
pre-run: tests/pre
run: tests/run
post-run: tests/post
attempts: 1
timeout: 10800
required-projects:
- openstack/kolla
- openstack/requirements
irrelevant-files:
- ^.*\.rst$
- ^doc/.*
- job:
name: kolla-ansible-centos-source
parent: kolla-ansible-base
nodeset: kolla-ansible-centos
voting: false
vars:
base_distro: centos
install_type: source
- job:
name: kolla-ansible-ubuntu-source
parent: kolla-ansible-base
nodeset: kolla-ansible-xenial
voting: false
vars:
base_distro: ubuntu
install_type: source
- job:
name: kolla-ansible-oraclelinux-source
parent: kolla-ansible-base
nodeset: kolla-ansible-centos
voting: false
vars:
base_distro: oraclelinux
install_type: source
- job:
name: kolla-ansible-centos-binary
parent: kolla-ansible-base
nodeset: kolla-ansible-centos
voting: false
vars:
base_distro: centos
install_type: binary
- job:
name: kolla-ansible-ubuntu-binary
parent: kolla-ansible-base
nodeset: kolla-ansible-xenial
voting: false
vars:
base_distro: ubuntu
install_type: binary
- job:
name: kolla-ansible-oraclelinux-binary
parent: kolla-ansible-base
nodeset: kolla-ansible-centos
voting: false
vars:
base_distro: oraclelinux
install_type: binary

View File

@ -1,40 +0,0 @@
---
- hosts: localhost
connection: local
become: True
tasks:
- name: Get api_interface name
set_fact: api_interface_address="{{ lookup('file', '/etc/nodepool/primary_node_private') }}"
- shell: "ip a | grep {{ api_interface_address }}"
register: api_interface_name
- set_fact: api_interface_name="{{ api_interface_name.stdout_lines[0].split(" ")[-1] }}"
- set_fact:
is_multinode: "{{ lookup('file', '/etc/nodepool/sub_nodes') }}"
- name: Ensure /etc/kolla dir
file:
path: /etc/kolla
state: "directory"
- name: Setup globals.yml
template:
src: "templates/globals-default.j2"
dest: "/etc/kolla/globals.yml"
- name: Copy passwords.yml
copy:
src: "../etc/kolla/passwords.yml"
dest: "/etc/kolla/passwords.yml"
- name: Ensure /etc/kolla/config directory
file:
path: /etc/kolla/config/nova
state: "directory"
- name: Setup overrides
template:
src: "templates/nova-compute-overrides.j2"
dest: "/etc/kolla/config/nova/nova-compute.conf"

View File

@ -1,26 +0,0 @@
---
- hosts: localhost
connection: local
tasks:
- name: Get node addresses
set_fact:
primary_node_address: "{{ lookup('file', '/etc/nodepool/primary_node_private') }}"
sub_node_addresses: "{{ lookup('file', '/etc/nodepool/sub_nodes_private').split('\n') }}"
- set_fact: node_group="{{ lookup('template', 'templates/inventory.j2')}}"
- name: Ensure /tmp/kolla exists
file:
path: "/tmp/kolla"
state: "directory"
- name: Copy default ansible kolla-ansible inventory
copy:
src: ../ansible/inventory/all-in-one
dest: /tmp/kolla/raw_inventory
- name: Replace localhost with IPs
replace:
path: /tmp/kolla/raw_inventory
regexp: "localhost.*$"
replace: "{{ node_group }}"

View File

@ -1,88 +0,0 @@
---
- hosts: all
tasks:
- name: Check node role
command: "cat /etc/nodepool/role"
register: node_role
- set_fact: node_role="{{ node_role.stdout }}"
- name: Ensure /tmp/logs dir
file:
path: "/tmp/logs"
state: "directory"
when:
- node_role == "sub"
- name: Get /tmp/logs symlink target
command: "readlink -f /tmp/logs"
register: logs_target
- name: Ensure primary node directories
file:
path: "{{ logs_target.stdout }}/{{ item }}"
state: "directory"
mode: 0777
when:
- node_role == "primary"
with_items:
- "subnodes"
- "docker_logs"
- "kolla_configs"
- "system_logs"
- "kolla"
- name: Ensure sub node directories
file:
path: "/tmp/logs/{{ item }}"
state: "directory"
mode: 0777
when:
- node_role == "sub"
with_items:
- "docker_logs"
- "kolla_configs"
- "system_logs"
- "kolla"
- name: Run diagnostics script
script: get_logs.sh
register: get_logs_result
failed_when: false
- name: Print get_logs output
debug:
msg: "{{ get_logs_result.stdout }}"
- name: Run dump_info script
script: ../tools/dump_info.sh
- name: Download logs from all subnodes
synchronize:
src: "/tmp/logs"
dest: "{{ logs_target.stdout }}/subnodes/{{ ansible_hostname }}"
mode: "pull"
when:
- node_role == "sub"
- name: Change permission of all log files
command: "chmod -R 777 {{ logs_target.stdout }}"
- name: Fail if get_logs has failed
fail:
msg: "{{ get_logs_result.stdout }}"
when: get_logs_result.rc != 0
- name: Copy inventory file to logs
copy:
src: "/tmp/kolla/raw_inventory"
dest: "{{ logs_target.stdout }}/ansible/inventory"
when:
- node_role == "primary"
- name: Copy hosts file to logs
copy:
src: "/etc/hosts"
dest: "{{ logs_target.stdout }}/system_logs/hosts"
when:
- node_role == "primary"

View File

@ -1,43 +1,68 @@
#!/bin/bash
set +o errexit
copy_logs() {
cp -rnL /var/lib/docker/volumes/kolla_logs/_data/* /tmp/logs/kolla/
cp -rnL /etc/kolla/* /tmp/logs/kolla_configs/
cp -rvnL /var/log/* /tmp/logs/system_logs/
LOG_DIR=/tmp/logs
cp -rnL /var/lib/docker/volumes/kolla_logs/_data/* ${LOG_DIR}/kolla/
cp -rnL /etc/kolla/* ${LOG_DIR}/kolla_configs/
cp -rvnL /var/log/* ${LOG_DIR}/system_logs/
if [[ -x "$(command -v journalctl)" ]]; then
journalctl --no-pager -u docker.service > /tmp/logs/system_logs/docker.log
journalctl --no-pager > ${LOG_DIR}/system_logs/syslog.txt
journalctl --no-pager -u docker.service > ${LOG_DIR}/system_logs/docker.log
else
cp /var/log/upstart/docker.log /tmp/logs/system_logs/docker.log
cp /var/log/upstart/docker.log ${LOG_DIR}/system_logs/docker.log
fi
}
check_failure() {
# Command failures after this point can be expected
set +o errexit
cp -r /etc/sudoers.d ${LOG_DIR}/system_logs/
cp /etc/sudoers ${LOG_DIR}/system_logs/sudoers.txt
docker images
docker ps -a
# All docker container's status are created, restarting, running, removing,
# paused, exited and dead. Containers without running status are treated as
# failure. removing is added in docker 1.13, just ignore it now.
failed_containers=$(docker ps -a --format "{{.Names}}" \
--filter status=created \
--filter status=restarting \
--filter status=paused \
--filter status=exited \
--filter status=dead)
df -h > ${LOG_DIR}/system_logs/df.txt
free > ${LOG_DIR}/system_logs/free.txt
parted -l > ${LOG_DIR}/system_logs/parted-l.txt
mount > ${LOG_DIR}/system_logs/mount.txt
env > ${LOG_DIR}/system_logs/env.txt
for failed in ${failed_containers}; do
docker logs --tail all ${failed} > /tmp/logs/docker_logs/${failed}
if [ `command -v dpkg` ]; then
dpkg -l > ${LOG_DIR}/system_logs/dpkg-l.txt
fi
if [ `command -v rpm` ]; then
rpm -qa > ${LOG_DIR}/system_logs/rpm-qa.txt
fi
# final memory usage and process list
ps -eo user,pid,ppid,lwp,%cpu,%mem,size,rss,cmd > ${LOG_DIR}/system_logs/ps.txt
# docker related information
(docker info && docker images && docker ps -a) > ${LOG_DIR}/system_logs/docker-info.txt
# ceph related logs
if [[ $(docker ps --filter name=ceph_mon --format "{{.Names}}") ]]; then
docker exec ceph_mon ceph -s > ${LOG_DIR}/kolla/ceph/ceph_s.txt
docker exec ceph_mon ceph osd df > ${LOG_DIR}/kolla/ceph/ceph_osd_df.txt
docker exec ceph_mon ceph osd tree > ${LOG_DIR}/kolla/ceph/ceph_osd_tree.txt
fi
for container in $(docker ps -a --format "{{.Names}}"); do
docker logs --tail all ${container} > ${LOG_DIR}/docker_logs/${container}.txt
done
copy_logs
# Rename files to .txt; this is so that when displayed via
# logs.openstack.org clicking results in the browser shows the
# files, rather than trying to send it to another app or make you
# download it, etc.
if [[ -n "$failed_containers" ]]; then
exit 1;
fi
# Rename all .log files to .txt files
for f in $(find ${LOG_DIR}/{system_logs,kolla,docker_logs} -name "*.log"); do
mv $f ${f/.log/.txt}
done
chmod -R 777 ${LOG_DIR}
find ${LOG_DIR}/{system_logs,kolla,docker_logs} -iname '*.txt' -execdir gzip -f -9 {} \+
find ${LOG_DIR}/{system_logs,kolla,docker_logs} -iname '*.json' -execdir gzip -f -9 {} \+
}
check_failure
copy_logs

28
tests/post.yml Normal file
View File

@ -0,0 +1,28 @@
---
- hosts: all
vars:
logs_dir: "/tmp/logs"
tasks:
- name: Run diagnostics script
script: get_logs.sh
register: get_logs_result
become: true
failed_when: false
- name: Print get_logs output
debug:
msg: "{{ get_logs_result.stdout }}"
- name: Download logs to executor
synchronize:
dest: "{{ zuul.executor.log_root }}/{{ inventory_hostname }}"
mode: pull
src: "{{ logs_dir }}/"
ignore_errors: yes
- name: Download /etc/hosts file to executor
synchronize:
src: "/etc/hosts"
dest: "{{ zuul.executor.log_root }}/{{inventory_hostname }}/"
mode: pull
ignore_errors: yes

31
tests/pre.yml Normal file
View File

@ -0,0 +1,31 @@
- hosts: all
vars:
logs_dir: "/tmp/logs"
tasks:
- name: Install dbus for debian system
apt: name=dbus
when:
- ansible_os_family == 'Debian'
become: true
- name: Ensure /tmp/logs/ dir
file:
path: "{{ logs_dir }}"
state: "directory"
- name: Ensure node directories
file:
path: "{{ logs_dir }}/{{ item }}"
state: "directory"
mode: 0777
with_items:
- "docker_logs"
- "kolla_configs"
- "system_logs"
- "kolla"
- "ansible"
- name: set new hostname based on ansible inventory file
hostname:
name: "{{ inventory_hostname }}"
become: true

96
tests/run.yml Normal file
View File

@ -0,0 +1,96 @@
---
- hosts: all
vars:
kolla_inventory_path: "/etc/kolla/inventory"
logs_dir: "/tmp/logs"
kolla_ansible_src_dir: "src/{{ zuul.project.canonical_hostname }}/openstack/kolla-ansible"
kolla_ansible_full_src_dir: "{{ zuul.executor.work_root }}/{{ kolla_ansible_src_dir }}"
tasks:
- name: ensure /etc/kolla exists
file:
path: "/etc/kolla"
state: "directory"
mode: 0777
become: true
- set_fact:
nodes: |
{% for host in hostvars %}
{{ host }} ansible_host={{ hostvars[host]['nodepool']['private_ipv4'] }} ansible_become=true ansible_user={{ hostvars[host]['ansible_user'] }}
{% endfor %}
- name: copy default ansible kolla-ansible inventory
copy:
src: "{{ kolla_ansible_full_src_dir }}/ansible/inventory/all-in-one"
dest: "{{ kolla_inventory_path }}"
delegate_to: "primary"
- name: replace localhost with IPs
replace:
path: "{{ kolla_inventory_path }}"
regexp: "localhost.*$"
replace: "{{ nodes }}"
delegate_to: "primary"
# FIXME: in multi node env, api_interface may be different on each node.
- name: detect api_interface_name variable
vars:
ansible_interface_name: "ansible_{{ item.replace('-', '_') }}"
api_interface_address: "{{ hostvars[inventory_hostname]['nodepool']['private_ipv4'] }}"
set_fact:
api_interface_name: "{{ item }}"
api_interface_address: "{{ api_interface_address }}"
when:
- hostvars[inventory_hostname][ansible_interface_name]['ipv4'] is defined
- hostvars[inventory_hostname][ansible_interface_name]['ipv4']['address'] == api_interface_address
with_items: "{{ ansible_interfaces }}"
delegate_to: "primary"
- name: generate global.yml file
template:
src: "{{ kolla_ansible_full_src_dir }}/tests/templates/globals-default.j2"
dest: /etc/kolla/globals.yml
delegate_to: "primary"
- name: ensure nova conf overrides dir exists
file:
path: "/etc/kolla/config/nova"
state: "directory"
mode: 0777
become: true
delegate_to: "primary"
- name: generate config overrides
template:
src: "{{ kolla_ansible_full_src_dir }}/tests/templates/nova-compute-overrides.j2"
dest: /etc/kolla/config/nova/nova-compute.conf
delegate_to: "primary"
- name: copy passwords.yml file
copy:
src: "{{ kolla_ansible_full_src_dir }}/etc/kolla/passwords.yml"
dest: /etc/kolla/passwords.yml
delegate_to: "primary"
- name: install kolla-ansible requirements
pip:
requirements: "{{ ansible_env.HOME }}/{{ kolla_ansible_src_dir }}/requirements.txt"
become: true
- name: generate passwords
shell: "{{ kolla_ansible_src_dir }}/tools/generate_passwords.py"
delegate_to: "primary"
- shell:
cmd: |
set -e
set -x
export BASE_DISTRO={{ base_distro }}
export INSTALL_TYPE={{ install_type }}
export NODEPOOL_TARBALLS_MIRROR=http://{{ zuul_site_mirror_fqdn }}:8080/tarballs
tools/setup_gate.sh
executable: /bin/bash
chdir: "{{ kolla_ansible_src_dir }}"
delegate_to: "primary"
environment: '{{ zuul | zuul_legacy_vars }}'

View File

@ -1,9 +1,8 @@
---
disable_selinux: "yes"
kolla_base_distro: "{{ base }}"
kolla_install_type: "{{ type }}"
kolla_base_distro: "{{ base_distro }}"
kolla_install_type: "{{ install_type }}"
{% if is_multinode %}
{% if hostvars|length > 2 %}
enable_haproxy: "no"
kolla_internal_vip_address: "{{ api_interface_address }}"
{% else %}
@ -20,3 +19,10 @@ enable_horizon: "yes"
enable_heat: "no"
openstack_logging_debug: "True"
openstack_service_workers: "1"
{% if 'ceph' in zuul.job %}
enable_ceph: "yes"
enable_cinder: "yes"
{% endif %}
disable_selinux: "yes"

View File

@ -1,6 +0,0 @@
{{ primary_node_address }} ansible_become=true ansible_connection=local
{% for addr in sub_node_addresses %}
{% if addr %}
{{ addr }} ansible_user=jenkins ansible_become=true ansible_ssh_private_key_file=/etc/nodepool/id_rsa
{% endif %}
{% endfor %}

View File

@ -63,7 +63,7 @@ sudo service docker stop
if [[ ${DISTRIB_CODENAME} == "trusty" ]]; then
sudo apt-get -y install --no-install-recommends btrfs-tools
setup_disk
echo "DOCKER_OPTS=\"-s btrfs --insecure-registry $(cat /etc/nodepool/primary_node_private):4000\"" | sudo tee /etc/default/docker
echo "DOCKER_OPTS=\"-s btrfs --insecure-registry 0.0.0.0/0\"" | sudo tee /etc/default/docker
sudo mount --make-shared /run
sudo service docker start
else
@ -71,7 +71,7 @@ else
sudo tee /etc/systemd/system/docker.service.d/kolla.conf << EOF
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --storage-driver overlay2 --insecure-registry $(cat /etc/nodepool/primary_node_private):4000
ExecStart=/usr/bin/dockerd --storage-driver overlay2 --insecure-registry 0.0.0.0/0
MountFlags=shared
EOF
sudo systemctl daemon-reload

View File

@ -6,19 +6,8 @@ set -o errexit
# Enable unbuffered output for Ansible in Jenkins.
export PYTHONUNBUFFERED=1
source /etc/nodepool/provider
NODEPOOL_MIRROR_HOST=${NODEPOOL_MIRROR_HOST:-mirror.$NODEPOOL_REGION.$NODEPOOL_CLOUD.openstack.org}
NODEPOOL_MIRROR_HOST=$(echo $NODEPOOL_MIRROR_HOST|tr '[:upper:]' '[:lower:]')
NODEPOOL_PYPI_MIRROR=${NODEPOOL_PYPI_MIRROR:-http://$NODEPOOL_MIRROR_HOST/pypi/simple}
GIT_PROJECT_DIR=$(mktemp -d)
# Just for mandre :)
if [[ ! -f /etc/sudoers.d/jenkins ]]; then
echo "jenkins ALL=(:docker) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/jenkins
fi
function clone_repos {
cat > /tmp/clonemap <<EOF
clonemap:
@ -33,8 +22,6 @@ EOF
}
function setup_config {
sudo mkdir /etc/kolla
sudo chmod -R 777 /etc/kolla
# Use Infra provided pypi.
# Wheel package mirror may be not compatible. So do not enable it.
PIP_CONF=$(mktemp)
@ -51,6 +38,14 @@ EOF
# /home/jenkins/workspace/gate-kolla-ansible-dsvm-deploy-centos-source-centos-7-nv
# NOTE(Jeffrey4l): use different a docker namespace name in case it pull image from hub.docker.io when deplying
GATE_IMAGES="cron,fluentd,glance,haproxy,keepalived,keystone,kolla-toolbox,mariadb,memcached,neutron,nova,openvswitch,rabbitmq,horizon"
# TODO(jeffrey4l): this doesn't work with zuulv3
if echo $ACTION | grep -q "ceph"; then
GATE_IMAGES+=",ceph,cinder"
fi
cat <<EOF | sudo tee /etc/kolla/kolla-build.conf
[DEFAULT]
include_header = /etc/kolla/header
@ -62,11 +57,11 @@ registry = 127.0.0.1:4000
push = true
[profiles]
gate = cron,fluentd,glance,haproxy,keepalived,keystone,kolla-toolbox,mariadb,memcached,neutron,nova,openvswitch,rabbitmq,horizon
gate = ${GATE_IMAGES}
EOF
if [[ "${DISTRO}" == "Debian" ]]; then
# Infra does not sign thier mirrors so we ignore gpg signing in the gate
# Infra does not sign their mirrors so we ignore gpg signing in the gate
echo "RUN echo 'APT::Get::AllowUnauthenticated \"true\";' > /etc/apt/apt.conf" | sudo tee -a /etc/kolla/header
# Optimize the repos to take advantage of the Infra provided mirrors for Ubuntu
@ -89,44 +84,18 @@ function detect_distro {
DISTRO=$(ansible all -i "localhost," -msetup -clocal | awk -F\" '/ansible_os_family/ {print $4}')
}
# NOTE(sdake): This works around broken nodepool on systems with only one
# private interface
# The big regex checks for IP addresses in the file
function setup_workaround_broken_nodepool {
if [[ `grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" /etc/nodepool/node_private | wc -l` -eq 0 ]]; then
cp /etc/nodepool/node /etc/nodepool/node_private
cp /etc/nodepool/sub_nodes /etc/nodepool/sub_nodes_private
fi
}
function setup_ssh {
sudo chown jenkins /etc/nodepool/id_rsa
sudo chmod 600 /etc/nodepool/id_rsa
}
function setup_inventory {
echo -e "127.0.0.1\tlocalhost" > /tmp/hosts
ansible-playbook tests/ansible_generate_inventory.yml
sudo chown root: /tmp/hosts
sudo chmod 644 /tmp/hosts
sudo mv /tmp/hosts /etc/hosts
}
function setup_ansible {
RAW_INVENTORY=/tmp/kolla/raw_inventory
mkdir /tmp/kolla
RAW_INVENTORY=/etc/kolla/inventory
# TODO(SamYaple): Move to virtualenv
sudo -H pip install -U "ansible>=2,<2.4" "docker-py>=1.6.0" "python-openstackclient" "python-neutronclient" "ara"
sudo -H pip install -U "ansible>=2,<2.4" "docker-py" "python-openstackclient" "python-neutronclient" "ara"
detect_distro
setup_inventory
sudo mkdir /etc/ansible
ara_location=$(python -c "import os,ara; print(os.path.dirname(ara.__file__))")
sudo tee /etc/ansible/ansible.cfg<<EOF
[defaults]
callback_plugins = /usr/lib/python2.7/site-packages/ara/plugins/callbacks:\$VIRTUAL_ENV/lib/python2.7/site-packages/ara/plugins/callbacks
callback_plugins = ${ara_location}/plugins/callbacks
host_key_checking = False
EOF
@ -138,24 +107,16 @@ function setup_node {
ansible-playbook -i ${RAW_INVENTORY} tools/playbook-setup-nodes.yml
}
function setup_logging {
# This directory is the directory that is copied with the devstack-logs
# publisher. It must exist at /home/jenkins/workspace/<job-name>/logs
mkdir logs
# For ease of access we symlink that logs directory to a known path
ln -s $(pwd)/logs /tmp/logs
mkdir -p /tmp/logs/{ansible,build,kolla,kolla_configs,system_logs}
}
function prepare_images {
sudo docker run -d -p 4000:5000 --restart=always -v /tmp/kolla_registry/:/var/lib/registry --name registry registry:2
sudo docker run -d -p 4000:5000 --restart=always -v /opt/kolla_registry/:/var/lib/registry --name registry registry:2
# NOTE(Jeffrey4l): Zuul adds all changes depend on to ZUUL_CHANGES
# variable. if find "openstack/kolla:" string, it means this patch depends
# on one of Kolla patch. Then build image by using Kolla's code.
# Otherwise, pull images from tarballs.openstack.org site.
if echo "$ZUUL_CHANGES" | grep -q -i "openstack/kolla:"; then
# NOTE(inc0): Publisher variable is set when Kolla runs publisher jobs.
# When that happens we don't build images, we download them from temp location.
if echo "$ZUUL_CHANGES" | grep -i "openstack/kolla:" && ! [[ $PUBLISHER ]]; then
pushd "${GIT_PROJECT_DIR}/kolla"
sudo tox -e "build-${BASE_DISTRO}-${INSTALL_TYPE}"
popd
@ -163,13 +124,11 @@ function prepare_images {
BRANCH=$(echo "$ZUUL_BRANCH" | cut -d/ -f2)
filename=${BASE_DISTRO}-${INSTALL_TYPE}-registry-${BRANCH}.tar.gz
wget -q -c -O "/tmp/$filename" \
"http://tarballs.openstack.org/kolla/images/$filename"
sudo tar xzf "/tmp/$filename" -C /tmp/kolla_registry
"${NODEPOOL_TARBALLS_MIRROR}/kolla/images/${TMP_REGISTRY}${filename}"
sudo tar xzf "/tmp/$filename" -C /opt/kolla_registry
fi
}
function sanity_check {
# Wait for service ready
sleep 15
@ -182,30 +141,45 @@ function sanity_check {
neutron --debug agent-list
tools/init-runonce
nova --debug boot --poll --image $(openstack image list | awk '/cirros/ {print $2}') --nic net-id=$(openstack network list | awk '/demo-net/ {print $2}') --flavor 1 kolla_boot_test
nova --debug list
# If the status is not ACTIVE, print info and exit 1
nova --debug show kolla_boot_test | awk '{buf=buf"\n"$0} $2=="status" && $4!="ACTIVE" {failed="yes"}; END {if (failed=="yes") {print buf; exit 1}}'
if echo $ACTION | grep -q "ceph"; then
openstack volume create --size 2 test_volume
openstack server add volume kolla_boot_test test_volume --device /dev/vdb
fi
}
function get_logs {
ansible-playbook -i ${RAW_INVENTORY} tests/ansible_get_logs.yml > /tmp/logs/ansible/get-logs
check_failure() {
# All docker container's status are created, restarting, running, removing,
# paused, exited and dead. Containers without running status are treated as
# failure. removing is added in docker 1.13, just ignore it now.
failed_containers=$(sudo docker ps -a --format "{{.Names}}" \
--filter status=created \
--filter status=restarting \
--filter status=paused \
--filter status=exited \
--filter status=dead)
if [[ -n "$failed_containers" ]]; then
exit 1;
fi
}
setup_logging
tools/dump_info.sh
clone_repos
setup_workaround_broken_nodepool
setup_ssh
setup_ansible
setup_config
setup_node
ansible-playbook -e type=$INSTALL_TYPE -e base=$BASE_DISTRO tests/ansible_generate_config.yml > /tmp/logs/ansible/generate_config
tools/kolla-ansible -i ${RAW_INVENTORY} bootstrap-servers > /tmp/logs/ansible/bootstrap-servers
sudo tools/generate_passwords.py
prepare_images
trap get_logs EXIT
if echo $ACTION | grep -q "ceph"; then
ansible-playbook -i ${RAW_INVENTORY} tests/ansible_setup_ceph_disks.yml > /tmp/logs/ansible/setup_ceph_disks
fi
# Create dummy interface for neutron
ansible -m shell -i ${RAW_INVENTORY} -a "ip l a fake_interface type dummy" all
@ -232,7 +206,7 @@ tools/kolla-ansible -i ${RAW_INVENTORY} -vvv upgrade > /tmp/logs/ansible/upgrade
# run prechecks again
tools/kolla-ansible -i ${RAW_INVENTORY} -vvv prechecks > /tmp/logs/ansible/prechecks2
get_logs
ara generate html /tmp/logs/playbook_reports/
gzip --recursive --best /tmp/logs/playbook_reports/
check_failure