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