From fe9878c228514f3e7739f04aec34d0bb16372edf Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Thu, 7 Jan 2016 17:59:12 +0000 Subject: [PATCH] Gate: Bootstrap Host with updated CPU Map The different cloud providers for OpenStack-CI sometimes make use of hardware which libvirt does not appropriately map. This results in gate check failures as the nova scheduler is unable to find a suitable host on which to build the test VM's. This patch implements an extra set of tasks into the bootstrap process which adjusts the libvirt cpu map to resolve this issue. Implements: blueprint gate-split Change-Id: I666f53e01066bf8bff4d28fa012eadae7c958116 --- scripts/gate-check-commit.sh | 4 ++ tests/roles/bootstrap-host/defaults/main.yml | 3 ++ .../bootstrap-host/tasks/install-apt.yml | 10 ++++ tests/roles/bootstrap-host/tasks/main.yml | 6 +++ .../tasks/prepare_libvirt_service.yml | 53 +++++++++++++++++++ tests/roles/bootstrap-host/vars/ubuntu.yml | 5 ++ 6 files changed, 81 insertions(+) create mode 100644 tests/roles/bootstrap-host/tasks/prepare_libvirt_service.yml diff --git a/scripts/gate-check-commit.sh b/scripts/gate-check-commit.sh index 524b22042c..12bb9ebe39 100755 --- a/scripts/gate-check-commit.sh +++ b/scripts/gate-check-commit.sh @@ -97,6 +97,10 @@ if [ -f /etc/nodepool/provider -a -s /etc/nodepool/provider ]; then export BOOTSTRAP_OPTS="${BOOTSTRAP_OPTS} bootstrap_host_ubuntu_security_repo=${UBUNTU_REPO}" fi + # Update the libvirt cpu map with a gate64 cpu model. This enables nova + # live migration for 64bit guest OSes on heterogenous cloud "hardware". + export BOOTSTRAP_OPTS="${BOOTSTRAP_OPTS} bootstrap_host_libvirt_config=yes" + fi # Bootstrap an AIO diff --git a/tests/roles/bootstrap-host/defaults/main.yml b/tests/roles/bootstrap-host/defaults/main.yml index 8a38a80353..a5d25638b6 100644 --- a/tests/roles/bootstrap-host/defaults/main.yml +++ b/tests/roles/bootstrap-host/defaults/main.yml @@ -16,6 +16,9 @@ # Boolean option to implement OpenStack-Ansible configuration for an AIO bootstrap_host_aio_config: yes +# Boolean option to implement OpenStack-CI LibVirt Configuration Changes +bootstrap_host_libvirt_config: no + ## Swap memory # If there is no swap memory present, the bootstrap will create a loopback disk # for the purpose of having swap memory available. Swap is required for some of diff --git a/tests/roles/bootstrap-host/tasks/install-apt.yml b/tests/roles/bootstrap-host/tasks/install-apt.yml index ddb5b47267..ec81230a6b 100644 --- a/tests/roles/bootstrap-host/tasks/install-apt.yml +++ b/tests/roles/bootstrap-host/tasks/install-apt.yml @@ -95,3 +95,13 @@ when: bootstrap_host_mongodb_service | bool tags: - install-mongodb + +- name: Install LibVirt packages + apt: + name: "{{ item }}" + state: present + with_items: + - "{{ packages_libvirt }}" + when: bootstrap_host_libvirt_config | bool + tags: + - install-libvirt diff --git a/tests/roles/bootstrap-host/tasks/main.yml b/tests/roles/bootstrap-host/tasks/main.yml index 9074c17fae..51f8975c21 100644 --- a/tests/roles/bootstrap-host/tasks/main.yml +++ b/tests/roles/bootstrap-host/tasks/main.yml @@ -108,3 +108,9 @@ - include: prepare_mongodb_users.yml tags: - prepare-mongodb-users + +# Prepare the LibVirt Service for Nova +- include: prepare_libvirt_service.yml + when: bootstrap_host_libvirt_config | bool + tags: + - prepare-libvirt-service diff --git a/tests/roles/bootstrap-host/tasks/prepare_libvirt_service.yml b/tests/roles/bootstrap-host/tasks/prepare_libvirt_service.yml new file mode 100644 index 0000000000..73c08f3d5e --- /dev/null +++ b/tests/roles/bootstrap-host/tasks/prepare_libvirt_service.yml @@ -0,0 +1,53 @@ +--- +# Copyright 2016, Rackspace US, Inc. +# +# 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. + +- name: Download LibVirt CPU map configuration script + get_url: + url: "http://git.openstack.org/cgit/openstack-dev/devstack/plain/tools/cpu_map_update.py" + dest: /openstack/cpu_map_update.py + validate_certs: yes + mode: 755 + register: libvirt_cpu_map_download + tags: + - libvirt-cpu-map-download + +# Update the libvirt cpu map with a gate64 cpu model. This enables nova +# live migration for 64bit guest OSes on heterogenous cloud "hardware". +- name: Execute LibVirt CPU map configuration script + shell: /openstack/cpu_map_update.py /usr/share/libvirt/cpu_map.xml + when: libvirt_cpu_map_download | changed + tags: + - libvirt-cpu-map-updated + +# libvirt detects various settings on startup, as we potentially changed +# the system configuration (modules, filesystems), we need to restart +# libvirt to detect those changes. Use a stop start as otherwise the new +# cpu_map is not loaded properly on some systems (Ubuntu). +- name: Stop libvirt-bin + service: + name: "{{ servicename_libvirt }}" + state: stopped + when: libvirt_cpu_map_download | changed + tags: + - libvirt-service-stop + +- name: Start libvirt-bin + service: + name: "{{ servicename_libvirt }}" + state: started + when: libvirt_cpu_map_download | changed + tags: + - libvirt-service-start + diff --git a/tests/roles/bootstrap-host/vars/ubuntu.yml b/tests/roles/bootstrap-host/vars/ubuntu.yml index 40ccbefabd..41cd59c2ac 100644 --- a/tests/roles/bootstrap-host/vars/ubuntu.yml +++ b/tests/roles/bootstrap-host/vars/ubuntu.yml @@ -37,3 +37,8 @@ packages_mongodb: - mongodb-clients - mongodb-server - python-pymongo + +packages_libvirt: + - libvirt-bin + +servicename_libvirt: libvirt-bin