From 83208d840831ec12d8c15c3a8e5e0e3475050e90 Mon Sep 17 00:00:00 2001 From: Yury Kulazhenkov Date: Fri, 9 Feb 2024 16:18:40 +0200 Subject: [PATCH] Update usage of generic_plugin in service During the pre phase the plugin should be called with WithSkipVFConfiguration option to prevent VF configuration. In the post phase plugin should be executed as is. Signed-off-by: Yury Kulazhenkov --- cmd/sriov-network-config-daemon/service.go | 12 +++++------- cmd/sriov-network-config-daemon/service_test.go | 5 +++++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/sriov-network-config-daemon/service.go b/cmd/sriov-network-config-daemon/service.go index 0d38ad4c65..1917ed63cc 100644 --- a/cmd/sriov-network-config-daemon/service.go +++ b/cmd/sriov-network-config-daemon/service.go @@ -206,14 +206,12 @@ func getPlugin(setupLog logr.Logger, phase string, case consts.Baremetal: switch phase { case PhasePre: - configPlugin, err = newGenericPluginFunc(hostHelpers) - if err != nil { - return nil, fmt.Errorf("failed to create generic plugin for %v", err) - } + configPlugin, err = newGenericPluginFunc(hostHelpers, generic.WithSkipVFConfiguration()) case PhasePost: - // TODO add initialization for the generic plugin for the post phase - setupLog.Info("post phase is not implemented for generic plugin yet, skip") - return nil, nil + configPlugin, err = newGenericPluginFunc(hostHelpers) + } + if err != nil { + return nil, fmt.Errorf("failed to create generic plugin for %v", err) } case consts.VirtualOpenStack: switch phase { diff --git a/cmd/sriov-network-config-daemon/service_test.go b/cmd/sriov-network-config-daemon/service_test.go index 9f90fa306d..d6da3dbb7d 100644 --- a/cmd/sriov-network-config-daemon/service_test.go +++ b/cmd/sriov-network-config-daemon/service_test.go @@ -236,6 +236,11 @@ var _ = Describe("Service", func() { "/etc/sriov-operator/sriov-interface-result.yaml": getTestResultFileContent("InProgress", ""), }, }) + hostHelpers.EXPECT().DiscoverSriovDevices(hostHelpers).Return([]sriovnetworkv1.InterfaceExt{{ + Name: "enp216s0f0np0", + }}, nil) + genericPlugin.EXPECT().OnNodeStateChange(newNodeStateContainsDeviceMatcher("enp216s0f0np0")).Return(true, false, nil) + genericPlugin.EXPECT().Apply().Return(nil) Expect(runServiceCmd(&cobra.Command{}, []string{})).NotTo(HaveOccurred()) testHelpers.GinkgoAssertFileContentsEquals("/etc/sriov-operator/sriov-interface-result.yaml", string(getTestResultFileContent("Succeeded", "")))