From 1d59534f26c39d1c5627620c906e7e9a7802690a Mon Sep 17 00:00:00 2001 From: Rocky Date: Tue, 23 Feb 2021 00:16:19 +1100 Subject: [PATCH] Add images_type Co-Authored-By: Jake Yip Change-Id: I18dcdbd928e56d8b172f9c14ed67809a07e8bdea --- manifests/compute/libvirt.pp | 32 +++++++++++++++++++ manifests/compute/rbd.pp | 25 ++++++++++++++- .../add_images_type-d922a1886acdcd12.yaml | 10 ++++++ spec/classes/nova_compute_libvirt_spec.rb | 2 ++ spec/classes/nova_compute_rbd_spec.rb | 2 -- 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/add_images_type-d922a1886acdcd12.yaml diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index 77423c445..3ea14152c 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -129,6 +129,11 @@ # (optional) Available capacity in MiB for file-backed memory. # Defaults to $::os_service_default # +# [*images_type*] +# (optional) VM Images format. +# Valid Values are raw, flat, qcow2, lvm, rbd, ploop, default +# Defaults to $::os_service_default +# # [*volume_use_multipath*] # (optional) Use multipath connection of the # iSCSI or FC volume. Volumes can be connected in the @@ -321,6 +326,7 @@ class nova::compute::libvirt ( $rx_queue_size = $::os_service_default, $tx_queue_size = $::os_service_default, $file_backed_memory = undef, + $images_type = $::os_service_default, $volume_use_multipath = $::os_service_default, $nfs_mount_options = $::os_service_default, $num_pcie_ports = $::os_service_default, @@ -564,6 +570,32 @@ in a future release. Use the enabled_perf_events parameter instead') } } + # TODO(tkajinam): Remove this implementation in X + if defined('$::nova::compute::rbd::ephemeral_storage') { + if $::nova::compute::rbd::ephemeral_storage { + # When nova::compute::rbd is evaluated before nova::compute::libvirt, we + # need to fail setting images_type because it would have been handled in + # nova::compute::rbd + if is_service_default($images_type) { + warning('nova::compute::libvirt::images_type will be required if rbd ephemeral storage is used.') + } elsif $images_type != 'rbd' { + fail('nova::compute::libvirt::images_type should be rbd if rbd ephemeral storage is used.') + } + } else { + nova_config { + 'libvirt/images_type': value => $images_type; + } + } + } else { + # This is when only nova::compute::libvirt is used, + # or when nova::compute::libvirt is evaluated before nova::compute::rbd + if !is_service_default($images_type) { + nova_config { + 'libvirt/images_type': value => $images_type; + } + } + } + nova_config { 'DEFAULT/compute_driver': value => $compute_driver; 'DEFAULT/preallocate_images': value => $preallocate_images; diff --git a/manifests/compute/rbd.pp b/manifests/compute/rbd.pp index 3f86f9625..3d9ff151d 100644 --- a/manifests/compute/rbd.pp +++ b/manifests/compute/rbd.pp @@ -125,8 +125,31 @@ class nova::compute::rbd ( } if $ephemeral_storage { + + # TODO(tkajinam): Remove this implementation in X + if defined('$::nova::compute::libvirt::images_type') { + # When nova::compute::libvirt is evaluated before nova::compute::rbd, we + # never set it here unless $::nova::compute::libvirt::images_type is + # default, for backwards compatibility + $images_type_real = $::nova::compute::libvirt::images_type + if is_service_default($images_type_real) { + warning('nova::compute::libvirt::images_type will be required if rbd ephemeral storage is used.') + nova_config { + 'libvirt/images_type': value => 'rbd'; + } + } elsif $images_type_real != 'rbd' { + fail('nova::compute::libvirt::images_type should be rbd if rbd ephemeral storage is used.') + } + } + else { + # This is when only nova::compute::rbd is used, + # or when nova::compute::rbd is evaluated before nova::compute::libvirt + nova_config { + 'libvirt/images_type': value => 'rbd'; + } + } + nova_config { - 'libvirt/images_type': value => 'rbd'; 'libvirt/images_rbd_pool': value => $libvirt_images_rbd_pool; 'libvirt/images_rbd_ceph_conf': value => $libvirt_images_rbd_ceph_conf; } diff --git a/releasenotes/notes/add_images_type-d922a1886acdcd12.yaml b/releasenotes/notes/add_images_type-d922a1886acdcd12.yaml new file mode 100644 index 000000000..98e411bc6 --- /dev/null +++ b/releasenotes/notes/add_images_type-d922a1886acdcd12.yaml @@ -0,0 +1,10 @@ +--- +features: + - Add new parameter "nova::compute::libvirt::images_type", VM Images format. + If default is specified, then use_cow_images flag is used instead of this + one. + +deprecations: + - The "images_type" parameter will be required if rbd ephemeral storage is + used in a future release. Ensure the parameter is set to 'rbd' if + the deployment use rbd as its ephemeral storage backend. diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index d42f67c21..97687408a 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -97,6 +97,7 @@ describe 'nova::compute::libvirt' do :preallocate_images => 'space', :rx_queue_size => 512, :tx_queue_size => 1024, + :images_type => 'raw', :volume_use_multipath => false, :nfs_mount_options => 'rw,intr,nolock', :num_pcie_ports => 16, @@ -133,6 +134,7 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('vnc/server_listen').with_value('0.0.0.0')} it { is_expected.to contain_nova_config('libvirt/rx_queue_size').with_value(512)} it { is_expected.to contain_nova_config('libvirt/tx_queue_size').with_value(1024)} + it { is_expected.to contain_nova_config('libvirt/images_type').with_value('raw')} it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value(false)} it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('rw,intr,nolock')} it { is_expected.to contain_nova_config('libvirt/num_pcie_ports').with_value(16)} diff --git a/spec/classes/nova_compute_rbd_spec.rb b/spec/classes/nova_compute_rbd_spec.rb index dc1b1a2b4..f0e51e77a 100644 --- a/spec/classes/nova_compute_rbd_spec.rb +++ b/spec/classes/nova_compute_rbd_spec.rb @@ -35,7 +35,6 @@ describe 'nova::compute::rbd' do it { is_expected.to contain_class('nova::params') } it 'configure nova.conf with default parameters' do - is_expected.to contain_nova_config('libvirt/images_type').with_value('rbd') is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_value('rbd') is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/etc/ceph/ceph.conf') is_expected.to contain_nova_config('libvirt/rbd_user').with_value('nova') @@ -59,7 +58,6 @@ describe 'nova::compute::rbd' do end it 'configure nova.conf with overridden parameters' do - is_expected.to contain_nova_config('libvirt/images_type').with_value('rbd') is_expected.to contain_nova_config('libvirt/images_rbd_pool').with_value('AnotherPool') is_expected.to contain_nova_config('libvirt/images_rbd_ceph_conf').with_value('/tmp/ceph.conf') is_expected.to contain_nova_config('libvirt/rbd_user').with_value('joe')