From ed763e6a5db5df4a0005dd57bd11b4c411557ea5 Mon Sep 17 00:00:00 2001 From: Steven Webster Date: Sat, 28 Mar 2020 17:23:16 -0400 Subject: [PATCH] Fix SR-IOV runtime manifest apply When an SR-IOV interface is configured, the platform's network runtime manifest is applied in order to apply the virtual function (VF) config and restart the interface. This results in sysinv being able to determine and populate the puppet hieradata with the virtual function PCI addresses. A side effect of the network manifest apply is that potentially all platform interfaces may be brought down/up if it is determined that their configuration has changed. This will likely be the case for a system which configures SR-IOV interfaces before initial unlock. A few issues have been encountered because of this, with some services not behaving well when the interface they are communicating over suddenly goes down. This commit makes the SR-IOV VF configuration much more targeted so that only the operation of setting the desired number of VFs is performed. Closes-Bug: #1868584 Change-Id: Ic867fccae89fe8bc9173598c3c84c94ba2d7511f Signed-off-by: Steven Webster --- .../src/modules/platform/manifests/network.pp | 40 ++++++++++++++++--- .../templates/sriov.enable-device.erb | 1 + 2 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 puppet-manifests/src/modules/platform/templates/sriov.enable-device.erb diff --git a/puppet-manifests/src/modules/platform/manifests/network.pp b/puppet-manifests/src/modules/platform/manifests/network.pp index 2d6964e6e..191fc3d18 100644 --- a/puppet-manifests/src/modules/platform/manifests/network.pp +++ b/puppet-manifests/src/modules/platform/manifests/network.pp @@ -170,25 +170,53 @@ class platform::network::routes ( } -define platform::interfaces::sriov_config( +define platform::interfaces::sriov_enable ( + $pf_addr, + $num_vfs, $vf_addrs, $vf_driver = undef ) { - if $vf_driver != undef { + if $num_vfs { + exec { "sriov-enable-device: ${title}": + command => template('platform/sriov.enable-device.erb'), + logoutput => true, + } + } +} + + +define platform::interfaces::sriov_bind ( + $pf_addr, + $num_vfs, + $vf_addrs, + $vf_driver = undef +) { + if ($vf_driver != undef) and length($vf_addrs) > 0 { ensure_resource(kmod::load, $vf_driver) - exec { "sriov-vf-bind-device: ${title}": + Anchor['platform::networking'] + -> exec { "sriov-vf-bind-device: ${title}": command => template('platform/sriov.bind-device.erb'), logoutput => true, - require => Kmod::Load[$vf_driver], + require => [ Kmod::Load[$vf_driver] ], } } } class platform::interfaces::sriov ( - $sriov_config = {} + $sriov_config = {}, + $runtime = false ) { - create_resources('platform::interfaces::sriov_config', $sriov_config, {}) + if $runtime { + create_resources('platform::interfaces::sriov_enable', $sriov_config, {}) + } else { + create_resources('platform::interfaces::sriov_bind', $sriov_config, {}) + } +} + + +class platform::interfaces::sriov::runtime { + class { 'platform::interfaces::sriov': runtime => true } } diff --git a/puppet-manifests/src/modules/platform/templates/sriov.enable-device.erb b/puppet-manifests/src/modules/platform/templates/sriov.enable-device.erb new file mode 100644 index 000000000..f23d7d09f --- /dev/null +++ b/puppet-manifests/src/modules/platform/templates/sriov.enable-device.erb @@ -0,0 +1 @@ +echo 0 > /sys/bus/pci/devices/<%= @pf_addr %>/sriov_numvfs; echo <%= @num_vfs -%> > /sys/bus/pci/devices/<%= @pf_addr %>/sriov_numvfs