Migrate to Zuul v3 native jobs

This corrects the path handling in the CI and removes a lot of
redundancy in the CI definitions. Also adds fixed log collection
from https://review.opendev.org/#/c/649526/ to make the CI pass.

Removes handling of ZUUL_CHANGES. It is not present in new jobs,
and its use case in Bifrost is completely unclear.

Eventually, we should rewrite the whole test-bifrost.sh in ansible,
but that's a much bigger task.

Change-Id: Id893e816a7806e7d75282628817288d8a34ab8af
This commit is contained in:
Dmitry Tantsur 2019-10-30 11:29:26 +01:00
parent 13e62f4eb2
commit 4bb71fc481
20 changed files with 54 additions and 391 deletions

View File

@ -1,9 +1,8 @@
- hosts: all
tasks:
- name: Copy files from {{ ansible_user_dir }}/workspace/ on node
- name: Copy files from {{ ansible_user_dir }}/ on node
synchronize:
src: '{{ ansible_user_dir }}/workspace/'
src: '{{ ansible_user_dir }}/'
dest: '{{ zuul.executor.log_root }}'
mode: pull
copy_links: true

5
playbooks/ci/pre.yaml Normal file
View File

@ -0,0 +1,5 @@
- hosts: all
roles:
- role: bindep
bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/bifrost'].src_dir }}"

14
playbooks/ci/run.yaml Normal file
View File

@ -0,0 +1,14 @@
- hosts: all
tasks:
- shell:
cmd: scripts/test-bifrost.sh
chdir: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/bifrost'].src_dir }}"
environment:
BUILD_IMAGE: "{{ build_image | default(false) | bool | lower }}"
ENABLE_KEYSTONE: "{{ enable_keystone | default(false) | bool | lower }}"
LOG_LOCATION: "{{ ansible_user_dir }}/logs"
UPPER_CONSTRAINTS_FILE: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/requirements'].src_dir }}/upper-constraints.txt"
WORKSPACE: "{{ ansible_user_dir }}/src/opendev.org"
USE_DHCP: "{{ use_dhcp | default(false) | bool | lower }}"
USE_VENV: "{{ use_venv | default(false) | bool | lower }}"
ZUUL_BRANCH: "{{ zuul.branch }}"

View File

@ -1,74 +0,0 @@
- hosts: all
name: Autoconverted job legacy-bifrost-integration-dhcp from old job gate-bifrost-integration-dhcp-ubuntu-xenial-nv
roles:
- role: bindep
bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/bifrost'].src_dir }}"
tasks:
- name: Ensure legacy workspace directory
file:
path: '{{ ansible_user_dir }}/workspace'
state: directory
- shell:
cmd: |
set -e
set -x
CLONEMAP=`mktemp`
REQS_DIR=`mktemp -d`
function cleanup {
mkdir -p $WORKSPACE
rm -rf $CLONEMAP $REQS_DIR
}
trap cleanup EXIT
cat > $CLONEMAP << EOF
clonemap:
- name: $ZUUL_PROJECT
dest: .
EOF
# zuul cloner works poorly if there are 2 names that are the
# same in here.
if [[ "$ZUUL_PROJECT" != "openstack/requirements" ]]; then
cat >> $CLONEMAP << EOF
- name: openstack/requirements
dest: $REQS_DIR
EOF
fi
/usr/zuul-env/bin/zuul-cloner -m $CLONEMAP --cache-dir /opt/git \
https://opendev.org $ZUUL_PROJECT openstack/requirements
# REQS_DIR is not set for openstack/requirements and there is also
# no need to copy in this case.
if [[ "$ZUUL_PROJECT" != "openstack/requirements" ]]; then
cp $REQS_DIR/upper-constraints.txt ./
fi
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
set -u
set -e
set -x
cd $WORKSPACE
/usr/zuul-env/bin/zuul-cloner --cache-dir /opt/git \
https://opendev.org \
openstack/bifrost \
openstack/diskimage-builder \
openstack/ironic \
openstack/python-ironicclient \
openstack/shade \
openstack/openstacksdk \
openstack/ironic-inspector \
openstack/python-ironic-inspector-client \
openstack/requirements
export GIT_BASE=$(pwd)
export UPPER_CONSTRAINTS_FILE=$WORKSPACE/upper-constraints.txt
export USE_VENV={{ use_venv | default(false) | bool | lower }}
cd openstack/bifrost
scripts/test-bifrost-inventory-dhcp.sh
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'

View File

@ -1,15 +0,0 @@
- hosts: all
tasks:
- name: Copy files from {{ ansible_user_dir }}/workspace/ on node
synchronize:
src: '{{ ansible_user_dir }}/workspace/'
dest: '{{ zuul.executor.log_root }}'
mode: pull
copy_links: true
verify_host: true
rsync_opts:
- --include=/logs/**
- --include=*/
- --exclude=*
- --prune-empty-dirs

View File

@ -1,74 +0,0 @@
- hosts: all
name: Autoconverted job legacy-bifrost-integration-dibipa-debian from old job gate-bifrost-integration-dibipa-debian-ubuntu-xenial-nv
roles:
- role: bindep
bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/bifrost'].src_dir }}"
tasks:
- name: Ensure legacy workspace directory
file:
path: '{{ ansible_user_dir }}/workspace'
state: directory
- shell:
cmd: |
set -e
set -x
CLONEMAP=`mktemp`
REQS_DIR=`mktemp -d`
function cleanup {
mkdir -p $WORKSPACE
rm -rf $CLONEMAP $REQS_DIR
}
trap cleanup EXIT
cat > $CLONEMAP << EOF
clonemap:
- name: $ZUUL_PROJECT
dest: .
EOF
# zuul cloner works poorly if there are 2 names that are the
# same in here.
if [[ "$ZUUL_PROJECT" != "openstack/requirements" ]]; then
cat >> $CLONEMAP << EOF
- name: openstack/requirements
dest: $REQS_DIR
EOF
fi
/usr/zuul-env/bin/zuul-cloner -m $CLONEMAP --cache-dir /opt/git \
https://opendev.org $ZUUL_PROJECT openstack/requirements
# REQS_DIR is not set for openstack/requirements and there is also
# no need to copy in this case.
if [[ "$ZUUL_PROJECT" != "openstack/requirements" ]]; then
cp $REQS_DIR/upper-constraints.txt ./
fi
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
set -u
set -e
set -x
cd $WORKSPACE
/usr/zuul-env/bin/zuul-cloner --cache-dir /opt/git \
https://opendev.org \
openstack/bifrost \
openstack/diskimage-builder \
openstack/ironic \
openstack/python-ironicclient \
openstack/shade \
openstack/openstacksdk \
openstack/ironic-inspector \
openstack/python-ironic-inspector-client \
openstack/requirements
export GIT_BASE=$(pwd)
export UPPER_CONSTRAINTS_FILE=$WORKSPACE/upper-constraints.txt
export USE_VENV={{ use_venv | default(false) | bool | lower }}
cd openstack/bifrost
scripts/test-bifrost-build-images.sh
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'

View File

@ -1,15 +0,0 @@
- hosts: all
tasks:
- name: Copy files from {{ ansible_user_dir }}/workspace/ on node
synchronize:
src: '{{ ansible_user_dir }}/workspace/'
dest: '{{ zuul.executor.log_root }}'
mode: pull
copy_links: true
verify_host: true
rsync_opts:
- --include=/logs/**
- --include=*/
- --exclude=*
- --prune-empty-dirs

View File

@ -1,83 +0,0 @@
- hosts: all
name: Autoconverted job legacy-bifrost-integration-tinyipa from old job gate-bifrost-integration-tinyipa-ubuntu-xenial
roles:
- role: bindep
bindep_dir: "{{ ansible_user_dir }}/{{ zuul.projects['opendev.org/openstack/bifrost'].src_dir }}"
tasks:
- name: Set script name for testing without Keystone
set_fact:
script_name: scripts/test-bifrost.sh
when: not (use_keystone | default(false) | bool)
- name: Set script name for testing with Keystone
set_fact:
script_name: scripts/test-bifrost-keystone-auth.sh
when: use_keystone | default(false) | bool
- name: Ensure legacy workspace directory
file:
path: '{{ ansible_user_dir }}/workspace'
state: directory
- shell:
cmd: |
set -e
set -x
CLONEMAP=`mktemp`
REQS_DIR=`mktemp -d`
function cleanup {
mkdir -p $WORKSPACE
rm -rf $CLONEMAP $REQS_DIR
}
trap cleanup EXIT
cat > $CLONEMAP << EOF
clonemap:
- name: openstack/bifrost
dest: .
EOF
# zuul cloner works poorly if there are 2 names that are the
# same in here.
if [[ "$ZUUL_PROJECT" != "openstack/requirements" ]]; then
cat >> $CLONEMAP << EOF
- name: openstack/requirements
dest: $REQS_DIR
EOF
fi
/usr/zuul-env/bin/zuul-cloner -m $CLONEMAP --cache-dir /opt/git \
https://opendev.org openstack/bifrost openstack/requirements
# REQS_DIR is not set for openstack/requirements and there is also
# no need to copy in this case.
if [[ "$ZUUL_PROJECT" != "openstack/requirements" ]]; then
cp $REQS_DIR/upper-constraints.txt ./
fi
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'
- shell:
cmd: |
set -u
set -e
set -x
cd $WORKSPACE
/usr/zuul-env/bin/zuul-cloner --cache-dir /opt/git \
https://opendev.org \
openstack/bifrost \
openstack/ironic \
openstack/python-ironicclient \
openstack/shade \
openstack/openstacksdk \
openstack/ironic-inspector \
openstack/python-ironic-inspector-client \
openstack/requirements
export GIT_BASE=$(pwd)
export UPPER_CONSTRAINTS_FILE=$WORKSPACE/upper-constraints.txt
export USE_VENV={{ use_venv | default(false) | bool | lower }}
cd openstack/bifrost
"{{ script_name }}"
executable: /bin/bash
chdir: '{{ ansible_user_dir }}/workspace'
environment: '{{ zuul | zuul_legacy_vars }}'

View File

@ -26,10 +26,6 @@ ironicclient_git_folder: The folder where the python-ironicclient code base
shade_git_folder: The folder where the shade code base has been cloned to.
ansible_env.ZUUL_CHANGES: The list of changes from Zuul that need to be
applied to the cloned repositories before testing
can proceed.
Dependencies
------------
@ -59,10 +55,6 @@ of the logic to properly handle an OpenStack CI environment node.
ironicclient_git_url: /opt/git/openstack/python-ironicclient
shade_git_url: /opt/git/openstack/shade
when: lookup('env', 'ZUUL_BRANCH') != ""
- name: "Set ci_testing_zuul_changes if ZUUL_CHANGES is set"
set_fact:
ci_testing_zuul_changes: true
when: lookup('env', 'ZUUL_CHANGES') != ""
roles:
- { role: bifrost-prep-for-install, when: skip_install is not defined }
- { role: bifrost-openstack-ci-prep, when: ci_testing_zuul is defined }

View File

@ -1,64 +0,0 @@
#!/usr/bin/env python
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Note(TheJulia): This script is no longer required by bifrost, however
# it may prove useful to those performing complex feature development
# within bifrost where they do not want to wait to rely upon CI jobs.
# DEPRICATED: Remove after Mitaka cycle
import re
import subprocess
import sys
if len(sys.argv) is 1:
print("ERROR: This script requires arguments!\n"
"%s repository_path review_url repository_name "
"zuul_changes" % sys.argv[0])
sys.exit(1)
repo_path = sys.argv[1]
review_url = sys.argv[2]
repo_name = sys.argv[3]
change_list = str(sys.argv[4]).split('^')
applicable_changes = [x for x in change_list if repo_name in x]
try:
for change in applicable_changes:
(project, branch, ref) = change.split(':')
if re.search(repo_name, project):
if not re.search(branch, subprocess.check_output(
['git', '-C', repo_path, 'status', '-s', '-b'])):
command = ['git', '-C', repo_path, 'checkout', branch]
subprocess.call(command, stdout=True)
command = ['git', '-C', repo_path, 'fetch',
review_url + "/" + repo_name, ref]
if subprocess.call(command, stdout=True) is 0:
if subprocess.call(
['git', '-C', repo_path, 'cherry-pick',
'-n', 'FETCH_HEAD'], stdout=True) is 0:
print("Applied %s" % ref)
else:
print("Failed to cherry pick %s onto %s branch %s"
% (ref, repo_name, branch))
sys.exit(1)
else:
print("Failed to download %s on to %s branch %s"
% (ref, repo_name, branch))
sys.exit(1)
except Exception as e:
print("Failed to process change: %s" % e)

View File

@ -20,7 +20,7 @@
mysql_username: "openstack_citest"
mysql_password: "openstack_citest"
disable_dnsmasq_dns: True
when: ci_testing_zuul_changes is defined
when: ci_testing_zuul is defined
- name: "Determine if OpenStack CI is missing an SSH key"
stat: path={{ssh_public_key_path}}

View File

@ -21,14 +21,11 @@
set_fact:
baremetal_json_file: "/tmp/baremetal.json"
when: baremetal_json_file is not defined
- name: "Set ci_testing flag if a list of changes are found in the environment variables"
- name: "Set ci_testing flag if running in the CI"
set_fact:
ci_testing: true
when: lookup('env', 'ZUUL_CHANGES') | length > 0
- name: "Set ci_testing_zuul if it appears we are running in upstream OpenStack CI"
set_fact:
ci_testing_zuul: true
when: "'bare-trusty' in ansible_hostname"
when: lookup('env', 'ZUUL_BRANCH') | length > 0
- name: "Collect process list if running in OpenStack CI"
command: ps aux
when: ci_testing_zuul is defined

View File

@ -33,21 +33,14 @@
ironicclient_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/python-ironicclient"
openstacksdk_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/openstacksdk"
shade_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/shade"
dib_git_url: "/opt/git/openstack/diskimage-builder"
dib_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/diskimage-builder"
ironicinspector_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/ironic-inspector"
ironicinspectorclient_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/python-ironic-inspector-client"
keystone_git_url: "/opt/git/openstack/keystone"
sushy_git_url: "/opt/git/openstack/sushy"
keystone_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/keystone"
sushy_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/sushy"
reqs_git_url: "{{ lookup('env', 'WORKSPACE') }}/openstack/requirements"
staging_drivers_git_url: "/opt/git/x/ironic-staging-drivers"
# TODO(TheJulia) Fix the above paths to be consistent, because the NV job gets the dib
# folder cloned, while the gate job does not. Likely need to work out a semi-hybrid
# solution.
staging_drivers_git_url: "{{ lookup('env', 'WORKSPACE') }}/x/ironic-staging-drivers"
when: lookup('env', 'ZUUL_BRANCH') | length > 0
- name: "Set ci_testing_zuul_changes if ZUUL_CHANGES is set"
set_fact:
ci_testing_zuul_changes: true
when: lookup('env', 'ZUUL_CHANGES') | length > 0
- name: "Override the ipv4_gateway setting"
set_fact:
ipv4_gateway: "192.168.122.1"

View File

@ -8,7 +8,7 @@ set -o pipefail
# Note(TheJulia): If there is a workspace variable, we want to utilize that as
# the preference of where to put logs
SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
LOG_LOCATION="${WORKSPACE:-${SCRIPT_HOME}/..}/logs"
LOG_LOCATION="${LOG_LOCATION:-${SCRIPT_HOME}/../logs}"
VERBOSE_LOGS="${VERBOSE_LOGS:-False}"
@ -42,13 +42,17 @@ fi
if $(ip link &>/dev/null); then
ip -s link &> ${LOG_LOCATION}/interface_counters.log
fi
mkdir -p ${LOG_LOCATION}/all
sudo cp -a /var/log/* ${LOG_LOCATION}/all/.
sudo chown -R $USER ${LOG_LOCATION}/all
if $(journalctl --version &>/dev/null); then
cp -a /var/log/* ${LOG_LOCATION}/.
sudo journalctl -u libvirtd &> ${LOG_LOCATION}/libvirtd.log
sudo journalctl -u ironic-api &> ${LOG_LOCATION}/ironic-api.log
sudo journalctl -u ironic-conductor &> ${LOG_LOCATION}/ironic-conductor.log
sudo journalctl -u ironic-inspector &> ${LOG_LOCATION}/ironic-inspector.log
sudo journalctl -u libvirtd &> ${LOG_LOCATION}/libvirtd.log
sudo journalctl -u dnsmasq &> ${LOG_LOCATION}/dnsmasq.log
else
sudo cp /var/log/upstart/ironic-api.log ${LOG_LOCATION}/
sudo cp /var/log/upstart/ironic-conductor.log ${LOG_LOCATION}/
@ -62,14 +66,14 @@ cp /httpboot/ipxe.* ${LOG_LOCATION}/pxe/
cp -aL /httpboot/pxelinux.cfg/ ${LOG_LOCATION}/pxe/
# Copy baremetal information
source $HOME/openrc
source $HOME/openrc bifrost
for vm in $(openstack baremetal node list -c Name -f value); do
openstack baremetal node show $vm >> ${LOG_LOCATION}/baremetal.txt
done
if [ -d "/var/log/ironic" ]; then
sudo cp -a "/var/log/ironic" ${LOG_LOCATION}/ipa-logs
ls -la ${LOG_LOCATION}/ipa-logs
ls -la ${LOG_LOCATION}/ipa-logs
fi
sudo vbmc list &> ${LOG_LOCATION}/vbmc.txt

View File

@ -1 +0,0 @@
test-bifrost.sh

View File

@ -1 +0,0 @@
test-bifrost.sh

View File

@ -1 +0,0 @@
test-bifrost.sh

View File

@ -1 +0,0 @@
test-bifrost.sh

View File

@ -6,11 +6,12 @@ export PYTHONUNBUFFERED=1
SCRIPT_HOME="$(cd "$(dirname "$0")" && pwd)"
BIFROST_HOME=$SCRIPT_HOME/..
ANSIBLE_INSTALL_ROOT=${ANSIBLE_INSTALL_ROOT:-/opt/stack}
ENABLE_VENV="false"
USE_DHCP="false"
USE_DHCP="${USE_DHCP:-false}"
USE_VENV="${USE_VENV:-false}"
BUILD_IMAGE="false"
BUILD_IMAGE="${BUILD_IMAGE:-false}"
BAREMETAL_DATA_FILE=${BAREMETAL_DATA_FILE:-'/tmp/baremetal.json'}
ENABLE_KEYSTONE="${ENABLE_KEYSTONE:-false}"
ZUUL_BRANCH=${ZUUL_BRANCH:-}
# Set defaults for ansible command-line options to drive the different
# tests.
@ -39,10 +40,9 @@ CREATE_IPA_IMAGE=false
WRITE_INTERFACES_FILE=true
PROVISION_WAIT_TIMEOUT=${PROVISION_WAIT_TIMEOUT:-900}
NOAUTH_MODE=true
ENABLE_KEYSTONE=false
CLOUD_CONFIG=""
WAIT_FOR_DEPLOY=true
ZUUL_BRANCH=${ZUUL_BRANCH:-}
ENABLE_VENV=false
# This sets up the MySQL database like it's done for all OpenStack
# projects for CI testing.
@ -82,19 +82,6 @@ if [ "$ZUUL_BRANCH" != "" ] ; then
mysql_setup
fi
# NOTE(cinerama): We could remove this if we change the CI job to use
# USE_DHCP, BUILD_IMAGE, etc.
SOURCE=$(basename ${BASH_SOURCE[0]})
if [ $SOURCE = "test-bifrost-inventory-dhcp.sh" ]; then
USE_DHCP="true"
elif [ $SOURCE = "test-bifrost-venv.sh" ]; then
USE_VENV="true"
elif [ $SOURCE = "test-bifrost-build-images.sh" ]; then
BUILD_IMAGE="true"
elif [ $SOURCE = "test-bifrost-keystone-auth.sh" ]; then
ENABLE_KEYSTONE="true"
fi
if [ ${USE_VENV} = "true" ]; then
export VENV=/opt/stack/bifrost
$SCRIPT_HOME/env-setup.sh

View File

@ -1,6 +1,6 @@
- job:
name: bifrost-base
parent: legacy-base
parent: base
irrelevant-files:
- ^.*\.rst$
- ^bifrost/tests/.*$
@ -10,30 +10,33 @@
- ^test-requirements.txt$
- ^tools/.*$
- ^tox.ini$
pre-run: playbooks/ci/pre.yaml
run: playbooks/ci/run.yaml
post-run: playbooks/ci/post.yaml
required-projects:
- openstack/bifrost
- openstack/diskimage-builder
- openstack/ironic
- openstack/ironic-inspector
- openstack/keystone
- openstack/openstacksdk
- openstack/python-ironic-inspector-client
- openstack/python-ironicclient
- openstack/requirements
- openstack/shade
- openstack/sushy
- x/ironic-staging-drivers
- job:
name: bifrost-integration
parent: bifrost-base
required-projects:
# this is in addition to bifrost-base's required-projects
- openstack/diskimage-builder
- job:
name: bifrost-integration-dhcp
parent: bifrost-integration
run: playbooks/legacy/bifrost-integration-dhcp/run.yaml
post-run: playbooks/legacy/bifrost-integration-dhcp/post.yaml
timeout: 7200
vars:
use_dhcp: true
- job:
name: bifrost-integration-dhcp-ubuntu-xenial
@ -55,9 +58,9 @@
- job:
name: bifrost-integration-dibipa-debian
parent: bifrost-integration
run: playbooks/legacy/bifrost-integration-dibipa-debian/run.yaml
post-run: playbooks/legacy/bifrost-integration-dibipa-debian/post.yaml
timeout: 7200
vars:
build_image: true
- job:
name: bifrost-integration-dibipa-debian-ubuntu-xenial
@ -79,8 +82,6 @@
- job:
name: bifrost-integration-tinyipa
parent: bifrost-base
run: playbooks/legacy/bifrost-integration-tinyipa/run.yaml
post-run: playbooks/legacy/bifrost-integration-tinyipa/post.yaml
timeout: 3600
- job:
@ -93,7 +94,7 @@
parent: bifrost-integration-tinyipa
nodeset: ubuntu-xenial
vars:
use_keystone: true
enable_keystone: true
- job:
name: bifrost-integration-tinyipa-centos-7