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] 96dd49f1ae

Closes-Bug: #1946985
Change-Id: Idac29b0ea6794a52ae9146da8105ebbaf65ee9a3
(cherry picked from commit 1fe71cf5e3)
(cherry picked from commit f5ee885fff)
This commit is contained in:
Takashi Kajinami 2021-10-14 17:28:41 +09:00
parent 6d0b3d586e
commit ee7c31bf5f
5 changed files with 40 additions and 9 deletions

View File

@ -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'

View File

@ -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)
}

View File

@ -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'],

View File

@ -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,

View File

@ -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