Skip to content

Commit

Permalink
Update usage of generic_plugin in service
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ykulazhenkov committed Feb 14, 2024
1 parent 224a956 commit 0668e47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cmd/sriov-network-config-daemon/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions cmd/sriov-network-config-daemon/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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", "")))
Expand Down

0 comments on commit 0668e47

Please sign in to comment.