From 4989c7951f66eed700ace092629ac884cbd3a0a8 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Sun, 30 Aug 2020 17:16:46 +0900 Subject: [PATCH] Use os_service_default instead of undef to unset parameters This patch replaces usage of undef by os_service_default, so that we can simiplify the logics implemented in each manifests. Change-Id: I098594de598e52be181f32765d02774770ba3bc0 --- manifests/compute/libvirt.pp | 48 +++++++++++-------- ...t-os_service_default-9f5b72036276e9b1.yaml | 12 +++++ spec/classes/nova_compute_libvirt_spec.rb | 12 ++--- 3 files changed, 45 insertions(+), 27 deletions(-) create mode 100644 releasenotes/notes/compute-libvirt-os_service_default-9f5b72036276e9b1.yaml diff --git a/manifests/compute/libvirt.pp b/manifests/compute/libvirt.pp index 918ce8e83..af01cc61b 100644 --- a/manifests/compute/libvirt.pp +++ b/manifests/compute/libvirt.pp @@ -86,7 +86,7 @@ # (optional) Should unused base images be removed? # If undef is specified, remove the line in nova.conf # otherwise, use a boolean to remove or not the base images. -# Defaults to undef +# Defaults to $::os_service_default # # [*remove_unused_resized_minimum_age_seconds*] # (optional) Unused resized base images younger @@ -94,7 +94,7 @@ # If undef is specified, remove the line in nova.conf # otherwise, use a integer or a string to define after # how many seconds it will be removed. -# Defaults to undef +# Defaults to $::os_service_default # # [*remove_unused_original_minimum_age_seconds*] # (optional) Unused unresized base images younger @@ -102,7 +102,7 @@ # If undef is specified, remove the line in nova.conf # otherwise, use a integer or a string to define after # how many seconds it will be removed. -# Defaults to undef +# Defaults to $::os_service_default # # [*libvirt_service_name*] # (optional) libvirt service name. @@ -212,9 +212,9 @@ class nova::compute::libvirt ( $libvirt_inject_key = false, $libvirt_inject_partition = -2, $libvirt_enabled_perf_events = $::os_service_default, - $remove_unused_base_images = undef, - $remove_unused_resized_minimum_age_seconds = undef, - $remove_unused_original_minimum_age_seconds = undef, + $remove_unused_base_images = $::os_service_default, + $remove_unused_resized_minimum_age_seconds = $::os_service_default, + $remove_unused_original_minimum_age_seconds = $::os_service_default, $libvirt_service_name = $::nova::params::libvirt_service_name, $virtlock_service_name = $::nova::params::virtlock_service_name, $virtlog_service_name = $::nova::params::virtlog_service_name, @@ -385,33 +385,39 @@ class nova::compute::libvirt ( } } - if $remove_unused_resized_minimum_age_seconds != undef { - nova_config { - 'libvirt/remove_unused_resized_minimum_age_seconds': value => $remove_unused_resized_minimum_age_seconds; - } - } else { + if $remove_unused_resized_minimum_age_seconds == undef { + warning('Use $::os_service_default instead of undef for the remove_unused_resized_minimum_age_seconds \ +parameter. The current behavior for undef will be changed in a future release') nova_config { 'libvirt/remove_unused_resized_minimum_age_seconds': ensure => absent; } + } else { + nova_config { + 'libvirt/remove_unused_resized_minimum_age_seconds': value => $remove_unused_resized_minimum_age_seconds; + } } - if $remove_unused_base_images != undef { - nova_config { - 'DEFAULT/remove_unused_base_images': value => $remove_unused_base_images; - } - } else { + if $remove_unused_base_images == undef { + warning('Use $::os_service_default instead of undef for the remove_unused_base_images \ +parameter. The current behavior for undef will be changed in a future release') nova_config { 'DEFAULT/remove_unused_base_images': ensure => absent; } + } else { + nova_config { + 'DEFAULT/remove_unused_base_images': value => $remove_unused_base_images; + } } - if $remove_unused_original_minimum_age_seconds != undef { - nova_config { - 'DEFAULT/remove_unused_original_minimum_age_seconds': value => $remove_unused_original_minimum_age_seconds; - } - } else { + if $remove_unused_original_minimum_age_seconds == undef { + warning('Use $::os_service_default instead of undef for the remove_unused_original_minimum_age_seconds \ +parameter. The current behavior for undef will be changed in a future release') nova_config { 'DEFAULT/remove_unused_original_minimum_age_seconds': ensure => absent; } + } else { + nova_config { + 'DEFAULT/remove_unused_original_minimum_age_seconds': value => $remove_unused_original_minimum_age_seconds; + } } } diff --git a/releasenotes/notes/compute-libvirt-os_service_default-9f5b72036276e9b1.yaml b/releasenotes/notes/compute-libvirt-os_service_default-9f5b72036276e9b1.yaml new file mode 100644 index 000000000..135f1e014 --- /dev/null +++ b/releasenotes/notes/compute-libvirt-os_service_default-9f5b72036276e9b1.yaml @@ -0,0 +1,12 @@ +--- +upgrade: + - | + The default value of the following parameters has been changed to + $::os_service_default. The previous default, undef, can still be used to + remove parameters from config file, but this behavior will be removed + in a future release. Make sure that $::os_service_default is used instead + of undef. + + - ``nova::compute::libvirt::remove_unused_resized_minimum_age_seconds`` + - ``nova::compute::libvirt::remove_unused_base_images`` + - ``nova::compute::libvirt::remove_unused_original_minimum_age_seconds`` diff --git a/spec/classes/nova_compute_libvirt_spec.rb b/spec/classes/nova_compute_libvirt_spec.rb index c55e00037..c5e8ebac5 100644 --- a/spec/classes/nova_compute_libvirt_spec.rb +++ b/spec/classes/nova_compute_libvirt_spec.rb @@ -57,9 +57,9 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/inject_key').with_value(false)} it { is_expected.to contain_nova_config('libvirt/inject_partition').with_value(-2)} it { is_expected.to contain_nova_config('vnc/server_listen').with_value('127.0.0.1')} - it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_ensure('absent')} - it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_ensure('absent')} - it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_ensure('absent')} + it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value('')} + it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value('')} + it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value('')} it { is_expected.to contain_nova_config('libvirt/rx_queue_size').with_value('')} it { is_expected.to contain_nova_config('libvirt/tx_queue_size').with_value('')} it { is_expected.to contain_nova_config('libvirt/volume_use_multipath').with_value('')} @@ -292,9 +292,9 @@ describe 'nova::compute::libvirt' do it { is_expected.to contain_nova_config('libvirt/inject_key').with_value(false)} it { is_expected.to contain_nova_config('libvirt/inject_partition').with_value(-2)} it { is_expected.to contain_nova_config('vnc/server_listen').with_value('127.0.0.1')} - it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_ensure('absent')} - it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_ensure('absent')} - it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_ensure('absent')} + it { is_expected.to contain_nova_config('DEFAULT/remove_unused_base_images').with_value('')} + it { is_expected.to contain_nova_config('DEFAULT/remove_unused_original_minimum_age_seconds').with_value('')} + it { is_expected.to contain_nova_config('libvirt/remove_unused_resized_minimum_age_seconds').with_value('')} it { is_expected.to contain_nova_config('libvirt/nfs_mount_options').with_value('')} end