Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[switchdev 5/x] Add skipVFconfiguration option for generic_plugin #614

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
adrianchiris marked this conversation as resolved.
Show resolved Hide resolved
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
Loading