Skip to content

Commit

Permalink
Create instance of IB interface in the host object
Browse files Browse the repository at this point in the history
Signed-off-by: amaslennikov <[email protected]>
  • Loading branch information
almaslennikov committed Mar 26, 2024
1 parent f43b96a commit 7492ffd
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 14 deletions.
6 changes: 5 additions & 1 deletion pkg/helper/host.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ func NewHostHelpers(utilsHelper utils.CmdInterface,
func NewDefaultHostHelpers() (HostHelpersInterface, error) {
utilsHelper := utils.New()
mlxHelper := mlx.New(utilsHelper)
hostManager := host.NewHostManager(utilsHelper)
hostManager, err := host.NewHostManager(utilsHelper)
if err != nil {
log.Log.Error(err, "failed to create host manager")
return nil, err
}
storeManager, err := store.NewManager()
if err != nil {
log.Log.Error(err, "failed to create store manager")
Expand Down
38 changes: 34 additions & 4 deletions pkg/helper/mock/mock_helper.go

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

14 changes: 11 additions & 3 deletions pkg/host/manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package host

import (
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/infiniband"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/kernel"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/dputils"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host/internal/lib/ethtool"
Expand All @@ -24,6 +25,7 @@ type HostManagerInterface interface {
types.UdevInterface
types.SriovInterface
types.VdpaInterface
types.InfinibandInterface
}

type hostManager struct {
Expand All @@ -34,9 +36,10 @@ type hostManager struct {
types.UdevInterface
types.SriovInterface
types.VdpaInterface
types.InfinibandInterface
}

func NewHostManager(utilsInterface utils.CmdInterface) HostManagerInterface {
func NewHostManager(utilsInterface utils.CmdInterface) (HostManagerInterface, error) {
dpUtils := dputils.New()
netlinkLib := netlink.New()
ethtoolLib := ethtool.New()
Expand All @@ -45,7 +48,11 @@ func NewHostManager(utilsInterface utils.CmdInterface) HostManagerInterface {
sv := service.New(utilsInterface)
u := udev.New(utilsInterface)
v := vdpa.New(k, netlinkLib)
sr := sriov.New(utilsInterface, k, n, u, v, netlinkLib, dpUtils)
ib, err := infiniband.New(netlinkLib, k, n)
sr := sriov.New(utilsInterface, k, n, u, v, ib, netlinkLib, dpUtils)
if err != nil {
return nil, err
}

return &hostManager{
utilsInterface,
Expand All @@ -55,5 +62,6 @@ func NewHostManager(utilsInterface utils.CmdInterface) HostManagerInterface {
u,
sr,
v,
}
ib,
}, nil
}
38 changes: 34 additions & 4 deletions pkg/host/mock/mock_host.go

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

8 changes: 7 additions & 1 deletion pkg/platforms/platforms.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package platforms

import (
"sigs.k8s.io/controller-runtime/pkg/log"

"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/host"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/platforms/openshift"
"github.com/k8snetworkplumbingwg/sriov-network-operator/pkg/platforms/openstack"
Expand All @@ -24,7 +26,11 @@ func NewDefaultPlatformHelper() (Interface, error) {
return nil, err
}
utilsHelper := utils.New()
hostManager := host.NewHostManager(utilsHelper)
hostManager, err := host.NewHostManager(utilsHelper)
if err != nil {
log.Log.Error(err, "failed to create host manager")
return nil, err
}
openstackContext := openstack.New(hostManager)

return &platformHelper{
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/k8s/k8s_plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("K8s plugin", func() {
testCtrl = gomock.NewController(GinkgoT())

hostHelper = mock_helper.NewMockHostHelpersInterface(testCtrl)
realHostMgr := host.NewHostManager(hostHelper)
realHostMgr, _ := host.NewHostManager(hostHelper)

// proxy some functions to real host manager to simplify testing and to additionally validate manifests
for _, f := range []string{
Expand Down

0 comments on commit 7492ffd

Please sign in to comment.