From ee7c31bf5f3f8e5188df0ec2b201b31d47c8d923 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 14 Oct 2021 17:28:41 +0900 Subject: [PATCH] Do not use service resource to restart openvswitch service Conflicts: manifests/dpdk.pp Backport note: This was initially implemented to fix the regression caused by [1], however it turned out the same issue is triggered by the dependency implemented in puppet-ovn, so I'm backporting this to stable/wallaby as well. [1] 96dd49f1ae979d479ccb69b8e5f5dccd030cf7ff Closes-Bug: #1946985 Change-Id: Idac29b0ea6794a52ae9146da8105ebbaf65ee9a3 (cherry picked from commit 1fe71cf5e359c8f83f11b2673620be822423bf47) (cherry picked from commit f5ee885fffca3d079a014fb19aa96b5579375a6b) --- lib/puppet/type/vs_config.rb | 15 +++++++++++++++ manifests/dpdk.pp | 16 ++++++++++++---- manifests/ovs.pp | 14 +++++++++++--- spec/classes/vswitch_dpdk_spec.rb | 2 +- spec/classes/vswitch_ovs_spec.rb | 2 +- 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/lib/puppet/type/vs_config.rb b/lib/puppet/type/vs_config.rb index 8c605b33..30286556 100644 --- a/lib/puppet/type/vs_config.rb +++ b/lib/puppet/type/vs_config.rb @@ -31,6 +31,21 @@ Puppet::Type.newtype(:vs_config) do defaultto :true end + newparam(:restart) do + desc 'Should the openvswitch service be restarted' + + newvalues(:true, :false) + defaultto :false + end + + autorequire(:service) do + ['openvswitch'] + end + + autonotify(:service) do + ['restart openvswitch'] if self[:restart] + end + newproperty(:value) do desc 'Configuration value for the parameter' diff --git a/manifests/dpdk.pp b/manifests/dpdk.pp index 4efa38fa..46773f08 100644 --- a/manifests/dpdk.pp +++ b/manifests/dpdk.pp @@ -111,9 +111,9 @@ class vswitch::dpdk ( # lint:ignore:quoted_booleans if $enable_hw_offload { vs_config { 'other_config:hw-offload': - value => 'true', - notify => Service['openvswitch'], - wait => true, + value => 'true', + restart => true, + wait => true, } } # lint:endignore @@ -146,5 +146,13 @@ class vswitch::dpdk ( name => $::vswitch::params::ovs_service_name, } - create_resources ('vs_config', $dpdk_configs, $dpdk_dependencies) + # NOTE(tkajinam): This resource is defined to restart the openvswitch services + # when any vs_config resource with restart => true is enabled. + exec { 'restart openvswitch': + path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'], + command => "systemctl -q restart ${::vswitch::params::ovs_service_name}.service", + refreshonly => true, + } + + create_resources('vs_config', $dpdk_configs, $dpdk_dependencies) } diff --git a/manifests/ovs.pp b/manifests/ovs.pp index 7bc855d2..8065d2dc 100644 --- a/manifests/ovs.pp +++ b/manifests/ovs.pp @@ -87,9 +87,9 @@ class vswitch::ovs( # lint:ignore:quoted_booleans if $enable_hw_offload { vs_config { 'other_config:hw-offload': - value => 'true', - notify => Service['openvswitch'], - wait => true, + value => 'true', + restart => true, + wait => true, } } # lint:endignore @@ -127,6 +127,14 @@ class vswitch::ovs( Service['ovsdb-server'] ~> Service['openvswitch'] } + # NOTE(tkajinam): This resource is defined to restart the openvswitch service + # when any vs_config resource with restart => true is enabled. + exec { 'restart openvswitch': + path => ['/sbin', '/usr/sbin', '/bin', '/usr/bin'], + command => "systemctl -q restart ${::vswitch::params::ovs_service_name}.service", + refreshonly => true, + } + package { $::vswitch::params::ovs_package_name: ensure => $package_ensure, before => Service['openvswitch'], diff --git a/spec/classes/vswitch_dpdk_spec.rb b/spec/classes/vswitch_dpdk_spec.rb index d87a76bf..493292f7 100644 --- a/spec/classes/vswitch_dpdk_spec.rb +++ b/spec/classes/vswitch_dpdk_spec.rb @@ -80,7 +80,7 @@ describe 'vswitch::dpdk' do :value => '-n 2', :wait => false, ) is_expected.to contain_vs_config('other_config:hw-offload').with( - :value => 'true', :notify => 'Service[openvswitch]', :wait => true, + :value => 'true', :restart => true, :wait => true, ) is_expected.to contain_vs_config('other_config:emc-insert-inv-prob').with( :value => '0', :wait => false, diff --git a/spec/classes/vswitch_ovs_spec.rb b/spec/classes/vswitch_ovs_spec.rb index fe4baba5..0328b42a 100644 --- a/spec/classes/vswitch_ovs_spec.rb +++ b/spec/classes/vswitch_ovs_spec.rb @@ -96,7 +96,7 @@ describe 'vswitch::ovs' do end it 'configures hw-offload option' do is_expected.to contain_vs_config('other_config:hw-offload').with( - :value => 'true', :notify => 'Service[openvswitch]', :wait => true, + :value => 'true', :restart => true, :wait => true, ) end it 'configures disable_emc option' do