Skip to content

Commit

Permalink
Merge pull request #614 from ykulazhenkov/pr-phased-plugins
Browse files Browse the repository at this point in the history
[switchdev 5/x] Add skipVFconfiguration option for generic_plugin
  • Loading branch information
adrianchiris authored Feb 19, 2024
2 parents 508f615 + 2fe88a3 commit 644acd4
Show file tree
Hide file tree
Showing 10 changed files with 497 additions and 154 deletions.
7 changes: 6 additions & 1 deletion api/v1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,12 @@ func NeedToUpdateSriov(ifaceSpec *Interface, ifaceStatus *InterfaceExt) bool {
for _, groupSpec := range ifaceSpec.VfGroups {
if IndexInRange(vfStatus.VfID, groupSpec.VfRange) {
ingroup = true
if groupSpec.DeviceType != consts.DeviceTypeNetDevice {
if vfStatus.Driver == "" {
log.V(2).Info("NeedToUpdateSriov(): Driver needs update - has no driver",
"desired", groupSpec.DeviceType)
return true
}
if groupSpec.DeviceType != "" && groupSpec.DeviceType != consts.DeviceTypeNetDevice {
if groupSpec.DeviceType != vfStatus.Driver {
log.V(2).Info("NeedToUpdateSriov(): Driver needs update",
"desired", groupSpec.DeviceType, "current", vfStatus.Driver)
Expand Down
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
8 changes: 7 additions & 1 deletion cmd/sriov-network-config-daemon/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/platforms"
platformsMock "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/platforms/mock"
plugin "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/generic"
pluginsMock "github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/plugins/mock"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/systemd"
"github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/fakefilesystem"
Expand Down Expand Up @@ -128,7 +129,7 @@ var _ = Describe("Service", func() {
genericPlugin = pluginsMock.NewMockVendorPlugin(testCtrl)
virtualPlugin = pluginsMock.NewMockVendorPlugin(testCtrl)

newGenericPluginFunc = func(_ helper.HostHelpersInterface) (plugin.VendorPlugin, error) {
newGenericPluginFunc = func(_ helper.HostHelpersInterface, _ ...generic.Option) (plugin.VendorPlugin, error) {
return genericPlugin, nil
}
newVirtualPluginFunc = func(_ helper.HostHelpersInterface) (plugin.VendorPlugin, error) {
Expand Down Expand Up @@ -235,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
30 changes: 8 additions & 22 deletions pkg/helper/mock/mock_helper.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 644acd4

Please sign in to comment.