From 14572c3153870b4fbe61022018346f234b6fcdcd Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Wed, 7 Nov 2018 20:36:50 +0000 Subject: [PATCH] Fix nova-lxd tests for bionic. This patch adjusts the nova-lxd deployment so that it works correctly with LXD3 and bionic. * Update the zuul job and project config to switch from xenial to bionic. * Change the variable lxd_storage_pool to always have a defined value in the role defaults. This variable represents the name of the LXD storage pool which is distinct from any names associated with underlying storage. LXD storage pools created with 'lxd init' are always called 'default'. * Switch the role test storage backend from dir to ZFS. nova-lxd is currently not working for the dir backend as it expects the storage subsystem to support quotas. * Due to limitiations in nova-lxd it is necessary to ensure that the LXD storage pool name and ZFS pool names are both set to 'default'. Closes-Bug: #1800837 Change-Id: If1e48bb2e789e13f20435da19907b5adb7c1ef1f --- defaults/main.yml | 10 ++-- .../default-lxd-pool-1aa179bd77868cb0.yaml | 11 +++++ templates/lxd-init.sh.j2 | 5 +- templates/nova.conf.j2 | 2 +- tests/os_nova-overrides-lxd.yml | 2 + tests/test-create-zfs-dev.yml | 48 +++++++++++++++++++ tests/test.yml | 5 ++ zuul.d/jobs.yaml | 4 +- zuul.d/project.yaml | 4 +- 9 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 releasenotes/notes/default-lxd-pool-1aa179bd77868cb0.yaml create mode 100644 tests/test-create-zfs-dev.yml diff --git a/defaults/main.yml b/defaults/main.yml index 97cd61e6..7e162cc3 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -632,9 +632,13 @@ lxd_storage_backend: dir # This needs to be set in the user_secrets.yml file. #lxd_trust_password: -# This variable should be used with lxd when using a -# storage backend that utilizes storage pools (zfs) -#lxd_storage_pool: +# The name of the underlying storage pool created by, or consumed by +# lxd init. As an example this would be the name of a ZFS pool. +#lxd_init_storage_pool: pool + +# Nova requires the LXD storage pool name to be specified +lxd_storage_pool: default + # This variable should be used with lxd when using a # storage backend that utilizes storage pool if you # want to use a specific bloc device instead of loop diff --git a/releasenotes/notes/default-lxd-pool-1aa179bd77868cb0.yaml b/releasenotes/notes/default-lxd-pool-1aa179bd77868cb0.yaml new file mode 100644 index 00000000..3bbac8f3 --- /dev/null +++ b/releasenotes/notes/default-lxd-pool-1aa179bd77868cb0.yaml @@ -0,0 +1,11 @@ +--- +features: + - | + The nova configuration is updated to always specify an LXD storage pool + name when 'nova_virt_type' is 'lxd'. The variable 'lxd_storage_pool' is + defaulted to 'default', the LXD default storage pool name. A new variable + 'lxd_init_storage_pool' is introduced which specifies the underlying + storage pool name. 'lxd_init_storage_pool' is used by lxd init when setting + up the storage pool. If not provided, lxd init will not use this parameter + at all. Please see the lxd man page for further information about the + storage pool parameter. diff --git a/templates/lxd-init.sh.j2 b/templates/lxd-init.sh.j2 index 0f77703e..e37deff3 100644 --- a/templates/lxd-init.sh.j2 +++ b/templates/lxd-init.sh.j2 @@ -11,8 +11,8 @@ --network-address={{ lxd_bind_address }} \ --network-port={{ lxd_bind_port }} \ --storage-backend={{ lxd_storage_backend }} \ -{% if lxd_storage_pool is defined %} - --storage-pool={{ lxd_storage_pool }} \ +{% if lxd_init_storage_pool is defined %} + --storage-pool={{ lxd_init_storage_pool }} \ {% endif %} {% if lxd_storage_create_device is defined %} --storage-create-device={{ lxd_storage_create_device }} \ @@ -29,4 +29,3 @@ if [ $(findmnt /var/lib/lxd -o FSTYPE -n) == "btrfs" ]; then fi {% endif %} - diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index e3631c3a..b6489c31 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -280,7 +280,7 @@ hw_disk_discard = {{ nova_libvirt_hw_disk_discard }} disk_cachemodes = {{ nova_libvirt_disk_cachemodes }} {% endif %} -{% if nova_virt_type == 'lxd' and lxd_storage_pool is defined %} +{% if nova_virt_type == 'lxd' %} [lxd] pool= {{ lxd_storage_pool }} {% endif %} diff --git a/tests/os_nova-overrides-lxd.yml b/tests/os_nova-overrides-lxd.yml index 3c4ab82e..d0314c89 100644 --- a/tests/os_nova-overrides-lxd.yml +++ b/tests/os_nova-overrides-lxd.yml @@ -14,6 +14,8 @@ # limitations under the License. nova_virt_type: lxd +lxd_storage_backend: zfs +lxd_init_storage_pool: default tempest_test_whitelist: - tempest.scenario.test_server_basic_ops.TestServerBasicOps.test_server_basic_ops diff --git a/tests/test-create-zfs-dev.yml b/tests/test-create-zfs-dev.yml new file mode 100644 index 00000000..cc0ed0cc --- /dev/null +++ b/tests/test-create-zfs-dev.yml @@ -0,0 +1,48 @@ +--- +# Copyright 2018, BBC R&D +# +# 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: Configure ZFS backing storage + hosts: localhost + user: root + become: true + connection: local + tasks: + - block: + - name: Install ZFS packages + package: + name: "{{ zfs_package[ansible_distribution | lower] }}" + state: present + + - name: Create base directories + file: + path: "{{ item }}" + state: "directory" + with_items: + - /openstack + + - name: Create sparse ZFS backing file + command: "truncate -s 1024G /openstack/nova-lxd-zfs.img" + args: + creates: /openstack/nova-lxd-zfs.img + register: lxc_zfs_create + + - name: Create the ZFS pool + command: zpool create default /openstack/nova-lxd-zfs.img + args: + creates: /default + + vars: + zfs_package: + ubuntu: "zfsutils-linux" diff --git a/tests/test.yml b/tests/test.yml index b44c3442..d8aa9d44 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Setup ZFS pool for nova-lxd tests +- import_playbook: test-create-zfs-dev.yml + when: + - nova_virt_type is defined and nova_virt_type == "lxd" + # Setup the host - import_playbook: common/test-setup-host.yml diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 0c516a6f..72380d89 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -14,7 +14,7 @@ # limitations under the License. - job: - name: openstack-ansible-lxd-ubuntu-xenial - parent: openstack-ansible-functional-ubuntu-xenial + name: openstack-ansible-lxd-ubuntu-bionic + parent: openstack-ansible-functional-ubuntu-bionic vars: tox_env: lxd diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 7301a6cf..5a7d2488 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -21,7 +21,7 @@ - release-notes-jobs-python3 check: jobs: - - openstack-ansible-lxd-ubuntu-xenial + - openstack-ansible-lxd-ubuntu-bionic gate: jobs: - - openstack-ansible-lxd-ubuntu-xenial + - openstack-ansible-lxd-ubuntu-bionic