Do not use service resource to restart openvswitch service

Closes-Bug: #1946985
Change-Id: Idac29b0ea6794a52ae9146da8105ebbaf65ee9a3
This commit is contained in:
Takashi Kajinami 2021-10-14 17:28:41 +09:00
parent f94ebb98af
commit 1fe71cf5e3
5 changed files with 39 additions and 8 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

@ -120,9 +120,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
@ -155,6 +155,14 @@ class vswitch::dpdk (
name => $::vswitch::params::ovs_service_name,
}
# 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,
}
Service['openvswitch'] -> Vs_config<||>
create_resources('vs_config', $dpdk_configs, $dpdk_dependencies)

View File

@ -90,9 +90,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
@ -132,6 +132,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

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