From c801c6e97be5054c696da727a9d36bd42142b0cc Mon Sep 17 00:00:00 2001
From: Takashi Kajinami <tkajinam@redhat.com>
Date: Tue, 28 Dec 2021 13:31:43 +0900
Subject: [PATCH] Ensure hardware offload is disabled

This change ensures hardware offload is disabled. Previously when
hw_offload is false, puppet-vswitch didn't manage the configuration,
thus offload was kept enabled if it was enabled in advance.

Change-Id: I654c0f7f5a5efb845484cb610ff07effd4f33aa9
---
 manifests/dpdk.pp                 | 6 ++++++
 manifests/ovs.pp                  | 6 ++++++
 spec/classes/vswitch_dpdk_spec.rb | 4 +++-
 spec/classes/vswitch_ovs_spec.rb  | 6 ++++--
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/manifests/dpdk.pp b/manifests/dpdk.pp
index 14de30ba..ec6c4dff 100644
--- a/manifests/dpdk.pp
+++ b/manifests/dpdk.pp
@@ -124,6 +124,12 @@ class vswitch::dpdk (
       restart => true,
       wait    => true,
     }
+  } else {
+    vs_config { 'other_config:hw-offload':
+      ensure  => absent,
+      restart => true,
+      wait    => true,
+    }
   }
   # lint:endignore
 
diff --git a/manifests/ovs.pp b/manifests/ovs.pp
index dacba5e0..fbdf26fc 100644
--- a/manifests/ovs.pp
+++ b/manifests/ovs.pp
@@ -94,6 +94,12 @@ class vswitch::ovs(
       restart => true,
       wait    => true,
     }
+  } else {
+    vs_config { 'other_config:hw-offload':
+      ensure  => absent,
+      restart => true,
+      wait    => true,
+    }
   }
   # lint:endignore
 
diff --git a/spec/classes/vswitch_dpdk_spec.rb b/spec/classes/vswitch_dpdk_spec.rb
index 493292f7..bbdee22c 100644
--- a/spec/classes/vswitch_dpdk_spec.rb
+++ b/spec/classes/vswitch_dpdk_spec.rb
@@ -46,7 +46,9 @@ describe 'vswitch::dpdk' do
         is_expected.to contain_vs_config('other_config:dpdk-extra').with(
           :value => nil, :wait => false,
         )
-        is_expected.to_not contain_vs_config('other_config:hw-offload')
+        is_expected.to contain_vs_config('other_config:hw-offload').with(
+          :ensure => 'absent', :restart => true, :wait => true,
+        )
         is_expected.to_not contain_vs_config('other_config:emc-insert-inv-prob')
         is_expected.to_not contain_vs_config('other_config:vlan-limit')
 
diff --git a/spec/classes/vswitch_ovs_spec.rb b/spec/classes/vswitch_ovs_spec.rb
index bb0bab93..39227e2a 100644
--- a/spec/classes/vswitch_ovs_spec.rb
+++ b/spec/classes/vswitch_ovs_spec.rb
@@ -22,8 +22,10 @@ describe 'vswitch::ovs' do
         is_expected.to contain_class('vswitch::params')
       end
 
-      it 'configures hw-offload option to false' do
-          is_expected.to_not contain_vs_config('other_config:hw-offload')
+      it 'clears hw-offload option' do
+        is_expected.to contain_vs_config('other_config:hw-offload').with(
+          :ensure => 'absent', :restart => true, :wait => true,
+        )
       end
 
       it 'configures disable_emc option to false' do