From fb9a08d9726b79d2dcca34dab00150a1b62ef529 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Tue, 28 Dec 2021 13:25:48 +0900 Subject: [PATCH] Use undef instead of $::os_service_default $::os_service_default is not used in puppet-vswitch. This change deprecates usage of it to prepare replacing it by undef, which is commonly used instead. Change-Id: Ibfe94720e28f5ce46977b2db2afa82a6888c28cb --- manifests/dpdk.pp | 24 ++++++++++++++++--- manifests/ovs.pp | 17 ++++++++++--- ...e-os_service_default-25185711be0702a9.yaml | 8 +++++++ spec/classes/vswitch_dpdk_spec.rb | 4 +++- spec/classes/vswitch_ovs_spec.rb | 6 +++-- 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/replace-os_service_default-25185711be0702a9.yaml diff --git a/manifests/dpdk.pp b/manifests/dpdk.pp index 14de30ba..99ee5da6 100644 --- a/manifests/dpdk.pp +++ b/manifests/dpdk.pp @@ -41,7 +41,7 @@ # # [*vlan_limit*] # (optional) Number of vlan layers allowed. -# Default to $::os_service_default +# Default to undef # # [*revalidator_cores*] # (Optional) Number of cores to be used for OVS Revalidator threads. @@ -71,7 +71,7 @@ class vswitch::dpdk ( $socket_mem = undef, $enable_hw_offload = false, $disable_emc = false, - $vlan_limit = $::os_service_default, + $vlan_limit = undef, $revalidator_cores = undef, $handler_cores = undef, $vs_config = {}, @@ -83,6 +83,13 @@ class vswitch::dpdk ( validate_legacy(Hash, 'validate_hash', $vs_config) kmod::load { 'vfio-pci': } + if is_service_default($vlan_limit) { + warning('Usage of $::os_service_default for vlan_limit is deprecated. Use undef instead') + $vlan_limit_real = undef + } else { + $vlan_limit_real = $vlan_limit + } + if $::osfamily != 'Redhat' { fail( "${::osfamily} not yet supported for dpdk installation by puppet-vswitch") } @@ -134,7 +141,18 @@ class vswitch::dpdk ( } } - if ! is_service_default($vlan_limit) { + if is_service_default($vlan_limit) { + warning('Usage of $::os_service_default for vlan_limit is deprecated. Use undef instead') + vs_config { 'other_config:vlan-limit': + ensure => absent, + wait => true, + } + } elsif $vlan_limit == undef { + vs_config { 'other_config:vlan-limit': + ensure => absent, + wait => true, + } + } else { vs_config { 'other_config:vlan-limit': value => "${vlan_limit}", wait => true, diff --git a/manifests/ovs.pp b/manifests/ovs.pp index dacba5e0..4e6beacc 100644 --- a/manifests/ovs.pp +++ b/manifests/ovs.pp @@ -31,7 +31,7 @@ # # [*vlan_limit*] # (optional) Number of vlan layers allowed. -# Default to $::os_service_default +# Default to undef # # [*vs_config*] # (optional) allow configuration of arbitary vsiwtch configurations. @@ -45,7 +45,7 @@ class vswitch::ovs( $dkms_ensure = false, $enable_hw_offload = false, $disable_emc = false, - $vlan_limit = $::os_service_default, + $vlan_limit = undef, $vs_config = {}, ) { @@ -104,7 +104,18 @@ class vswitch::ovs( } } - if ! is_service_default($vlan_limit) { + if is_service_default($vlan_limit) { + warning('Usage of $::os_service_default for vlan_limit is deprecated. Use undef instead') + vs_config { 'other_config:vlan-limit': + ensure => absent, + wait => true, + } + } elsif $vlan_limit == undef { + vs_config { 'other_config:vlan-limit': + ensure => absent, + wait => true, + } + } else { vs_config { 'other_config:vlan-limit': value => "${vlan_limit}", wait => true, diff --git a/releasenotes/notes/replace-os_service_default-25185711be0702a9.yaml b/releasenotes/notes/replace-os_service_default-25185711be0702a9.yaml new file mode 100644 index 00000000..5af3de67 --- /dev/null +++ b/releasenotes/notes/replace-os_service_default-25185711be0702a9.yaml @@ -0,0 +1,8 @@ +--- +deprecations: + - | + Usage of ``$::os_service_default`` fact for the following two parameters + have been deprecated. Use ``undef`` instead. + + - ``ovs::ovs::vlan_limit`` + - ``ovs::dpdk::vlan_limit`` diff --git a/spec/classes/vswitch_dpdk_spec.rb b/spec/classes/vswitch_dpdk_spec.rb index 493292f7..cb3fcccc 100644 --- a/spec/classes/vswitch_dpdk_spec.rb +++ b/spec/classes/vswitch_dpdk_spec.rb @@ -48,7 +48,9 @@ describe 'vswitch::dpdk' do ) is_expected.to_not contain_vs_config('other_config:hw-offload') is_expected.to_not contain_vs_config('other_config:emc-insert-inv-prob') - is_expected.to_not contain_vs_config('other_config:vlan-limit') + is_expected.to contain_vs_config('other_config:vlan-limit').with( + :ensure => 'absent', :wait => true, + ) end end diff --git a/spec/classes/vswitch_ovs_spec.rb b/spec/classes/vswitch_ovs_spec.rb index bb0bab93..2ca5f4ac 100644 --- a/spec/classes/vswitch_ovs_spec.rb +++ b/spec/classes/vswitch_ovs_spec.rb @@ -30,8 +30,10 @@ describe 'vswitch::ovs' do is_expected.to_not contain_vs_config('other_config:emc-insert-inv-prob') end - it 'does not set vlan-limit option' do - is_expected.to_not contain_vs_config('other_config:vlan-limit') + it 'clears vlan-limit option' do + is_expected.to contain_vs_config('other_config:vlan-limit').with( + :ensure => 'absent', :wait => true, + ) end it 'configures service' do