Backport changes of zuul jobs and definitions to pike

Mostly from current master, but without unit tests.

This commit squashes together the following patches:
https://review.openstack.org/#/c/515209/
https://review.openstack.org/#/c/524224/
https://review.openstack.org/#/c/524689/
https://review.openstack.org/#/c/526113/
https://review.openstack.org/#/c/526114/
https://review.openstack.org/#/c/526935/
https://review.openstack.org/#/c/526936/
https://review.openstack.org/#/c/527027/
https://review.openstack.org/#/c/527106/
https://review.openstack.org/#/c/528002/
https://review.openstack.org/#/c/528076/
https://review.openstack.org/#/c/528275/
https://review.openstack.org/#/c/528359/
https://review.openstack.org/#/c/529341/
https://review.openstack.org/#/c/529944/
https://review.openstack.org/#/c/531208/
https://review.openstack.org/#/c/535522/
https://review.openstack.org/#/c/535879/
https://review.openstack.org/#/c/536611/
https://review.openstack.org/#/c/539686/

Most of the work was done by Andrea Frittoli and
Monty Taylor. Below is the complete list of original
authors (hopefully correctly ordered by surname):
Co-Authored-By: Clark Boylan <clark.boylan@gmail.com>
Co-Authored-By: Andrea Frittoli <andrea.frittoli@gmail.com>
Co-Authored-By: yong sheng gong <gong.yongsheng@99cloud.net>
Co-Authored-By: Jens Harbott <j.harbott@x-ion.de>
Co-Authored-By: Andreas Jaeger <aj@suse.com>
Co-Authored-By: Monty Taylor <mordred@inaugust.com>
Co-Authored-By: Dean Troyer <dtroyer@gmail.com>

Change-Id: Ia93bd480f260ee2c8bf56131e59a440a176259ee
This commit is contained in:
Luigi Toscano 2018-02-19 16:39:30 +01:00
parent 68fbb912bd
commit 8565ea8578
24 changed files with 451 additions and 48 deletions

View File

@ -1,28 +1,31 @@
# - nodeset:
# name: openstack-single-node
# nodes:
# - name: controller
# label: ubuntu-xenial
# groups:
# - name: tempest
# nodes:
# - controller
- nodeset:
name: openstack-single-node
nodes:
- name: controller
label: ubuntu-xenial
groups:
- name: tempest
nodes:
- controller
# - nodeset:
# name: openstack-two-node
# nodes:
# - name: controller
# label: ubuntu-xenial
# - name: compute1
# label: ubuntu-xenial
# groups:
# - name: tempest
# nodes:
# - controller
# - name: compute
# nodes:
# - controller
# - compute1
- nodeset:
name: openstack-two-node
nodes:
- name: controller
label: ubuntu-xenial
- name: compute1
label: ubuntu-xenial
groups:
- name: tempest
nodes:
- controller
- name: compute
nodes:
- controller
- compute1
- name: subnode
nodes:
- compute1
- job:
name: devstack
@ -39,9 +42,11 @@
- openstack/requirements
- openstack/swift
roles:
- zuul: openstack-infra/devstack-gate
- zuul: openstack-infra/openstack-zuul-jobs
timeout: 7200
vars:
test_matrix_configs: [neutron, tlsproxy]
devstack_localrc:
DATABASE_PASSWORD: secretdatabase
RABBIT_PASSWORD: secretrabbit
@ -57,6 +62,7 @@
FLOATING_HOST_MASK: 23
SWIFT_REPLICAS: 1
SWIFT_START_ALL_SERVICES: false
SWIFT_HASH: 1234123412341234
LOGFILE: /opt/stack/logs/devstacklog.txt
LOG_COLOR: false
VERBOSE: true
@ -71,12 +77,127 @@
devstack_services:
horizon: false
tempest: false
zuul_copy_output:
'{{ devstack_conf_dir }}/local.conf': 'logs'
'{{ devstack_conf_dir }}/localrc': 'logs'
'{{ devstack_conf_dir }}/.stackenv': 'logs'
'{{ devstack_log_dir }}/dstat-csv.log': 'logs'
'{{ devstack_log_dir }}/devstacklog.txt': 'logs'
'{{ devstack_log_dir }}/devstacklog.txt.summary': 'logs'
'{{ devstack_full_log}}': 'logs'
'{{ stage_dir }}/verify_tempest_conf.log': 'logs'
'{{ stage_dir }}/apache': 'logs'
'{{ stage_dir }}/apache_config': 'logs'
'{{ stage_dir }}/etc': 'logs'
'/var/log/rabbitmq': 'logs'
'/var/log/postgresql': 'logs'
'/var/log/mysql.err': 'logs'
'/var/log/mysql.log': 'logs'
'/var/log/libvirt': 'logs'
'/etc/sudoers': 'logs'
'/etc/sudoers.d': 'logs'
'{{ stage_dir }}/iptables.txt': 'logs'
'{{ stage_dir }}/df.txt': 'logs'
'{{ stage_dir }}/pip2-freeze.txt': 'logs'
'{{ stage_dir }}/pip3-freeze.txt': 'logs'
'{{ stage_dir }}/dpkg-l.txt': 'logs'
'{{ stage_dir }}/rpm-qa.txt': 'logs'
'{{ stage_dir }}/core': 'logs'
'{{ stage_dir }}/listen53.txt': 'logs'
'{{ stage_dir }}/deprecations.log': 'logs'
'/var/log/ceph': 'logs'
'/var/log/openvswitch': 'logs'
'/var/log/glusterfs': 'logs'
'/etc/glusterfs/glusterd.vol': 'logs'
'/etc/resolv.conf': 'logs'
'/var/log/unbound.log': 'logs'
extensions_to_txt:
conf: True
log: True
localrc: True
stackenv: True
summary: True
pre-run: playbooks/pre.yaml
run: playbooks/devstack.yaml
post-run: playbooks/post.yaml
irrelevant-files:
# Documentation related
- ^.*\.rst$
- ^api-ref/.*$
- ^doc/.*$
- ^releasenotes/.*$
# Translations
- ^.*/locale/.*po$
- job:
name: devstack-multinode
parent: devstack
description: Base devstack multinode job
nodeset: openstack-two-node
# NOTE(andreaf) The multinode job is useful to see the setup of different
# services on different nodes, however the subnode configuration is not
# ready yet. Until then this job should stay non-voting.
voting: false
- job:
name: devstack-tox-base
parent: devstack
description: |
Base job for devstack-based functional tests that use tox.
This job is not intended to be run directly. It's just here
for organizational purposes for devstack-tox-functional and
devstack-tox-functional-consumer.
post-run: playbooks/tox/post.yaml
vars:
tox_envlist: functional
tox_install_siblings: false
- job:
name: devstack-tox-functional
parent: devstack-tox-base
description: |
Base job for devstack-based functional tests that use tox.
Runs devstack, then runs the tox ``functional`` environment,
then collects tox/testr build output like normal tox jobs.
Turns off tox sibling installation. Projects may be involved
in the devstack deployment and so may be in the required-projects
list, but may not want to test against master of the other
projects in their tox env. Child jobs can set tox_install_siblings
to True to re-enable sibling processing.
run: playbooks/tox/run-both.yaml
- job:
name: devstack-tox-functional-consumer
parent: devstack
description: |
Base job for devstack-based functional tests for projects that
consume the devstack cloud.
This base job should only be used by projects that are not involved
in the devstack deployment step, but are instead projects that are using
devstack to get a cloud against which they can test things.
Runs devstack in pre-run, then runs the tox ``functional`` environment,
then collects tox/testr build output like normal tox jobs.
Turns off tox sibling installation. Projects may be involved
in the devstack deployment and so may be in the required-projects
list, but may not want to test against master of the other
projects in their tox env. Child jobs can set tox_install_siblings
to True to re-enable sibling processing.
pre-run:
- playbooks/devstack.yaml
- playbooks/tox/pre.yaml
run: playbooks/tox/run.yaml
- project:
check:
jobs:
- devstack
- devstack-multinode
gate:
jobs:
- devstack

View File

@ -1,4 +1,32 @@
- hosts: all
become: True
vars:
devstack_log_dir: "{{ devstack_base_dir|default('/opt/stack') }}/logs/"
devstack_conf_dir: "{{ devstack_base_dir|default('/opt/stack') }}/devstack/"
devstack_full_log: "{{ devstack_early_log|default('/opt/stack/logs/devstack-early.txt') }}"
tasks:
# NOTE(andreaf) If the tempest service is enabled, a tempest.log is
# generated as part of lib/tempest, as a result of verify_tempest_config
- name: Check if a tempest log exits
stat:
path: "{{ devstack_conf_dir }}/tempest.log"
register: tempest_log
- name: Link post-devstack tempest.log
file:
src: "{{ devstack_conf_dir }}/tempest.log"
dest: "{{ stage_dir }}/verify_tempest_conf.log"
state: hard
when: tempest_log.stat.exists
roles:
- export-devstack-journal
- fetch-devstack-log-dir
- apache-logs-conf
- devstack-project-conf
# capture-system-logs should be the last role before stage-output
- capture-system-logs
- role: stage-output
# NOTE(andreaf) We need fetch-devstack-log-dir only as long as the base job
# starts pulling logs for us from {{ ansible_user_dir }}/logs.
# Meanwhile we already store things in ansible_user_dir and use
# fetch-devstack-log-dir setting devstack_base_dir
- role: fetch-devstack-log-dir
devstack_base_dir: "{{ ansible_user_dir }}"

View File

@ -1,3 +1,13 @@
- hosts: controller
roles:
- role: test-matrix
test_matrix_role: primary
- hosts: subnode
roles:
- role: test-matrix
test_matrix_role: subnode
- hosts: all
roles:
- configure-swap
@ -8,15 +18,3 @@
- setup-devstack-cache
- start-fresh-logging
- write-devstack-local-conf
# TODO(jeblair): remove when configure-mirrors is fixed
tasks:
- name: Hack mirror_info
shell:
_raw_params: |
mkdir /etc/ci
cat << "EOF" > /etc/ci/mirror_info.sh
export NODEPOOL_UCA_MIRROR=http://mirror.dfw.rax.openstack.org/ubuntu-cloud-archive
EOF
args:
executable: /bin/bash
become: true

4
playbooks/tox/post.yaml Normal file
View File

@ -0,0 +1,4 @@
- hosts: all
roles:
- fetch-tox-output
- fetch-subunit-output

8
playbooks/tox/pre.yaml Normal file
View File

@ -0,0 +1,8 @@
- hosts: all
roles:
# Run bindep and test-setup after devstack so that they won't interfere
- role: bindep
bindep_profile: test
bindep_dir: "{{ zuul_work_dir }}"
- test-setup
- ensure-tox

View File

@ -0,0 +1,10 @@
- hosts: all
roles:
- run-devstack
# Run bindep and test-setup after devstack so that they won't interfere
- role: bindep
bindep_profile: test
bindep_dir: "{{ zuul_work_dir }}"
- test-setup
- ensure-tox
- tox

3
playbooks/tox/run.yaml Normal file
View File

@ -0,0 +1,3 @@
- hosts: all
roles:
- tox

View File

@ -0,0 +1,12 @@
Prepare apache configs and logs for staging
Make sure apache config files and log files are available in a linux flavor
independent location. Note that this relies on hard links, to the staging
directory must be in the same partition where the logs and configs are.
**Role Variables**
.. zuul:rolevar:: stage_dir
:default: {{ ansible_user_dir }}
The base stage directory.

View File

@ -0,0 +1,2 @@
devstack_base_dir: /opt/stack
stage_dir: "{{ ansible_user_dir }}"

View File

@ -0,0 +1,83 @@
- name: Ensure {{ stage_dir }}/apache exists
file:
path: "{{ stage_dir }}/apache"
state: directory
- name: Link apache logs on Debian/SuSE
block:
- name: Find logs
find:
path: "/var/log/apache2"
file_type: any
register: debian_suse_apache_logs
- name: Dereference files
stat:
path: "{{ item.path }}"
with_items: "{{ debian_suse_apache_logs.files }}"
register: debian_suse_apache_deref_logs
- name: Create hard links
file:
src: "{{ item.stat.lnk_source | default(item.stat.path) }}"
dest: "{{ stage_dir }}/apache/{{ item.stat.path | basename }}"
state: hard
with_items: "{{ debian_suse_apache_deref_logs.results }}"
when:
- item.stat.isreg or item.stat.islnk
when: ansible_os_family in ('Debian', 'Suse')
- name: Link apache logs on RedHat
block:
- name: Find logs
find:
path: "/var/log/httpd"
file_type: any
register: redhat_apache_logs
- name: Dereference files
stat:
path: "{{ item.path }}"
with_items: "{{ redhat_apache_logs.files }}"
register: redhat_apache_deref_logs
- name: Create hard links
file:
src: "{{ item.stat.lnk_source | default(item.stat.path) }}"
dest: "{{ stage_dir }}/apache/{{ item.stat.path | basename }}"
state: hard
with_items: "{{ redhat_apache_deref_logs.results }}"
when:
- item.stat.isreg or item.stat.islnk
when: ansible_os_family == 'Redhat'
- name: Ensure {{ stage_dir }}/apache_config apache_config exists
file:
path: "{{ stage_dir }}/apache_config"
state: directory
- name: Define config paths
set_fact:
apache_config_paths:
'Debian': '/etc/apache2/sites-enabled/'
'Suse': '/etc/apache2/conf.d/'
'Redhat': '/etc/httpd/conf.d/'
- name: Discover configurations
find:
path: "{{ apache_config_paths[ansible_os_family] }}"
file_type: any
register: apache_configs
no_log: true
- name: Dereference configurations
stat:
path: "{{ item.path }}"
with_items: "{{ apache_configs.files }}"
register: apache_configs_deref
no_log: true
- name: Link configurations
file:
src: "{{ item.stat.lnk_source | default(item.stat.path) }}"
dest: "{{ stage_dir }}/apache_config/{{ item.stat.path | basename }}"
state: hard
with_items: "{{ apache_configs_deref.results }}"
when: item.stat.isreg or item.stat.islnk
no_log: true

View File

@ -0,0 +1,20 @@
Stage a number of system type logs
Stage a number of different logs / reports:
- snapshot of iptables
- disk space available
- pip[2|3] freeze
- installed packages (dpkg/rpm)
- ceph, openswitch, gluster
- coredumps
- dns resolver
- listen53
- unbound.log
- deprecation messages
**Role Variables**
.. zuul:rolevar:: stage_dir
:default: {{ ansible_user_dir }}
The base stage directory.

View File

@ -0,0 +1 @@
devstack_base_dir: /opt/stack

View File

@ -0,0 +1,38 @@
# TODO(andreaf) Make this into proper Ansible
- name: Stage various logs and reports
shell:
cmd: |
sudo iptables-save > {{ stage_dir }}/iptables.txt
df -h > {{ stage_dir }}/df.txt
for py_ver in 2 3; do
if [[ `which python${py_ver}` ]]; then
python${py_ver} -m pip freeze > {{ stage_dir }}/pip${py_ver}-freeze.txt
fi
done
if [ `command -v dpkg` ]; then
dpkg -l> {{ stage_dir }}/dpkg-l.txt
fi
if [ `command -v rpm` ]; then
rpm -qa | sort > {{ stage_dir }}/rpm-qa.txt
fi
# gzip and save any coredumps in /var/core
if [ -d /var/core ]; then
sudo gzip -r /var/core
sudo cp -r /var/core {{ stage_dir }}/
fi
sudo ss -lntup | grep ':53' > {{ stage_dir }}/listen53.txt
# NOTE(andreaf) Service logs are already in logs/ thanks for the
# export-devstack-journal log. Apache logs are under apache/ thans to the
# apache-logs-conf role.
grep -i deprecat {{ stage_dir }}/logs/*.txt {{ stage_dir }}/apache/*.log | \
sed -r 's/[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}\.[0-9]{1,3}/ /g' | \
sed -r 's/[0-9]{1,2}\:[0-9]{1,2}\:[0-9]{1,2}/ /g' | \
sed -r 's/[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,4}/ /g' |
sed -r 's/\[.*\]/ /g' | \
sed -r 's/\s[0-9]+\s/ /g' | \
awk '{if ($0 in seen) {seen[$0]++} else {out[++n]=$0;seen[$0]=1}} END { for (i=1; i<=n; i++) print seen[out[i]]" :: " out[i] }' > {{ stage_dir }}/deprecations.log

View File

@ -0,0 +1,11 @@
Prepare OpenStack project configurations for staging
Prepare all relevant config files for staging.
This is helpful to avoid staging the entire /etc.
**Role Variables**
.. zuul:rolevar:: stage_dir
:default: {{ ansible_user_dir }}
The base stage directory.

View File

@ -0,0 +1 @@
stage_dir: "{{ ansible_user_dir }}"

View File

@ -0,0 +1,24 @@
- name: Ensure {{ stage_dir }}/etc exists
file:
path: "{{ stage_dir }}/etc"
state: directory
- name: Check which projects have a config folder
stat:
path: "/etc/{{ item.value.short_name }}"
with_dict: "{{ zuul.projects }}"
register: project_configs
- name: Copy configuration files
command: cp -pRL {{ item.stat.path }} {{ stage_dir }}/etc/{{ item.item.value.short_name }}
when: item.stat.exists
with_items: "{{ project_configs.results }}"
- name: Check if openstack has a config folder
stat:
path: "/etc/openstack"
register: openstack_configs
- name: Copy configuration files
command: cp -pRL /etc/openstack {{ stage_dir }}/etc/
when: openstack_configs.stat.exists

View File

@ -5,11 +5,17 @@ journal format as well as text. Also, export a syslog-style file with
kernal and sudo messages.
Writes the output to the ``logs/`` subdirectory of
``devstack_base_dir``.
``stage_dir``.
**Role Variables**
.. zuul:rolevar:: devstack_base_dir
:default: /opt/stack
The devstack base directory.
The devstack base directory. This is used to obtain the
``log-start-timestamp.txt``, used to filter the systemd journal.
.. zuul:rolevar:: stage_dir
:default: {{ ansible_user_dir }}
The base stage directory.

View File

@ -1 +1,2 @@
devstack_base_dir: /opt/stack
stage_dir: "{{ ansible_user_dir }}"

View File

@ -1,3 +1,11 @@
# NOTE(andreaf) This bypasses the stage-output role
- name: Ensure {{ stage_dir }}/logs exists
become: true
file:
path: "{{ stage_dir }}/logs"
state: directory
owner: "{{ ansible_user }}"
# TODO: convert this to ansible
- name: Export journal files
become: true
@ -7,7 +15,7 @@
name=""
for u in `systemctl list-unit-files | grep devstack | awk '{print $1}'`; do
name=$(echo $u | sed 's/devstack@/screen-/' | sed 's/\.service//')
journalctl -o short-precise --unit $u | tee {{ devstack_base_dir }}/logs/$name.txt > /dev/null
journalctl -o short-precise --unit $u | gzip - > {{ stage_dir }}/logs/$name.txt.gz
done
# Export the journal in export format to make it downloadable
@ -16,7 +24,7 @@
# debugging much easier. We don't do the native conversion here as
# some distros do not package that tooling.
journalctl -u 'devstack@*' -o export | \
xz --threads=0 - > {{ devstack_base_dir }}/logs/devstack.journal.xz
xz --threads=0 - > {{ stage_dir }}/logs/devstack.journal.xz
# The journal contains everything running under systemd, we'll
# build an old school version of the syslog with just the
@ -26,4 +34,4 @@
-t sudo \
--no-pager \
--since="$(cat {{ devstack_base_dir }}/log-start-timestamp.txt)" \
| tee {{ devstack_base_dir }}/logs/syslog.txt > /dev/null
| gzip - > {{ stage_dir }}/logs/syslog.txt.gz

View File

@ -1,5 +1,5 @@
- name: Run devstack
command: ./stack.sh
shell: ./stack.sh 2>&1
args:
chdir: "{{devstack_base_dir}}/devstack"
become: true

View File

@ -47,13 +47,27 @@ Write the local.conf file for use by devstack
This is a dictionary of key-value pairs which comprise
this section of the INI file.
.. zuul:rolevar:: devstack_base_services
:type: list
:default: {{ base_services | default(omit) }}
A list of base services which are enabled. Services can be added or removed
from this list via the ``devstack_services`` variable. This is ignored if
``base`` is set to ``False`` in ``devstack_services``.
.. zuul:rolevar:: devstack_services
:type: dict
A dictionary mapping service names to boolean values. If the
boolean value is ``false``, a ``disable_service`` line will be
emitted for the service name. If it is ``true``, then
``enable_service`` will be emitted. All other values are ignored.
``enable_service`` will be emitted. All other values are ignored.
The special key ``base`` can be used to enable or disable the base set of
services enabled by default. If ``base`` is found, it will processed before
all other keys. If its value is ``False`` a ``disable_all_services`` will be
emitted; if its value is ``True`` services from ``devstack_base_services``
will be emitted via ``ENABLED_SERVICES``.
.. zuul:rolevar:: devstack_plugins
:type: dict

View File

@ -1,2 +1,3 @@
devstack_base_dir: /opt/stack
devstack_local_conf_path: "{{ devstack_base_dir }}/devstack/local.conf"
devstack_base_services: "{{ enabled_services | default(omit) }}"

View File

@ -106,13 +106,13 @@ class VarGraph(object):
class LocalConf(object):
def __init__(self, localrc, localconf, services, plugins):
def __init__(self, localrc, localconf, base_services, services, plugins):
self.localrc = []
self.meta_sections = {}
if plugins:
self.handle_plugins(plugins)
if services:
self.handle_services(services)
if services or base_services:
self.handle_services(base_services, services or {})
if localrc:
self.handle_localrc(localrc)
if localconf:
@ -123,7 +123,13 @@ class LocalConf(object):
if v:
self.localrc.append('enable_plugin {} {}'.format(k, v))
def handle_services(self, services):
def handle_services(self, base_services, services):
enable_base_services = services.pop('base', True)
if enable_base_services and base_services:
self.localrc.append('ENABLED_SERVICES={}'.format(
",".join(base_services)))
else:
self.localrc.append('disable_all_services')
for k, v in services.items():
if v is False:
self.localrc.append('disable_service {}'.format(k))
@ -161,6 +167,7 @@ def main():
module = AnsibleModule(
argument_spec=dict(
plugins=dict(type='dict'),
base_services=dict(type='list'),
services=dict(type='dict'),
localrc=dict(type='dict'),
local_conf=dict(type='dict'),
@ -171,6 +178,7 @@ def main():
p = module.params
lc = LocalConf(p.get('localrc'),
p.get('local_conf'),
p.get('base_services'),
p.get('services'),
p.get('plugins'))
lc.write(p['path'])

View File

@ -4,6 +4,7 @@
devstack_local_conf:
path: "{{ devstack_local_conf_path }}"
plugins: "{{ devstack_plugins|default(omit) }}"
base_services: "{{ devstack_base_services|default(omit) }}"
services: "{{ devstack_services|default(omit) }}"
localrc: "{{ devstack_localrc|default(omit) }}"
local_conf: "{{ devstack_local_conf|default(omit) }}"