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

Add infiniband guid runtimeconf #28

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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ image: | $(BASE) ; $(info Building Docker image...) ## Build conatiner image

.PHONY: clean
clean: ; $(info Cleaning...) ## Cleanup everything
@$(GO) clean -modcache
@rm -rf $(GOPATH)
@rm -rf $(BUILDDIR)
@rm -rf test
Expand Down
25 changes: 18 additions & 7 deletions cmd/ib-sriov-cni/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/Mellanox/ib-sriov-cni/pkg/config"
"github.com/Mellanox/ib-sriov-cni/pkg/sriov"
localtypes "github.com/Mellanox/ib-sriov-cni/pkg/types"
"github.com/Mellanox/ib-sriov-cni/pkg/utils"
)

Expand All @@ -32,25 +33,35 @@ func init() {
runtime.LockOSThread()
}

func getGUIDFromConf(netConf *localtypes.NetConf) (string, error) {
// Take from runtime config if available
if netConf.RuntimeConfig.InfinibandGUID != "" {
return netConf.RuntimeConfig.InfinibandGUID, nil
}
// Take from CNI_ARGS if available
if guid, ok := netConf.Args.CNI["guid"]; ok {
return guid, nil
}

return "", fmt.Errorf(
"infiniBand SRIOV-CNI failed, no guid found from runtimeConfig/CNI_ARGS, please check mellanox ib-kubernets")
}

func cmdAdd(args *skel.CmdArgs) error {
netConf, err := config.LoadConf(args.StdinData)
if err != nil {
return fmt.Errorf("infiniBand SRI-OV CNI failed to load netconf: %v", err)
}

cniArgs := netConf.Args.CNI
if cniArgs[infiniBandAnnotation] != configuredInfiniBand {
if netConf.Args.CNI[infiniBandAnnotation] != configuredInfiniBand {
return fmt.Errorf(
"infiniBand SRIOV-CNI failed, InfiniBand status \"%s\" is not \"%s\" please check mellanox ib-kubernets",
infiniBandAnnotation, configuredInfiniBand)
}

guid, ok := cniArgs["guid"]
if !ok {
return fmt.Errorf(
"infiniBand SRIOV-CNI failed, no guid found from cni-args, please check mellanox ib-kubernets")
if netConf.GUID, err = getGUIDFromConf(netConf); err != nil {
return err
}
netConf.GUID = guid

if netConf.RdmaIso {
err = utils.EnsureRdmaSystemMode()
Expand Down
8 changes: 7 additions & 1 deletion pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ type NetConf struct {
HostIFNames string // VF netdevice name(s)
HostIFGUID string // VF netdevice GUID
ContIFNames string // VF names after in the container; used during deletion
GUID string `json:"-"` // VF Guid is allowed only read from cni-args of network attachment
GUID string `json:"-"` // Taken from either CNI_ARGS "guid" attribute or from RuntimeConfig
PKey string `json:"pkey"`
LinkState string `json:"link_state,omitempty"` // auto|enable|disable
RdmaIso bool `json:"rdmaIsolation,omitempty"`
RdmaNetState rdmatypes.RdmaNetState
Args struct {
CNI map[string]string `json:"cni"`
} `json:"args"`
RuntimeConfig RuntimeConf `json:"runtimeConfig,omitempty"`
}

// RuntimeConf represents the plugin's runtime configurations
type RuntimeConf struct {
InfinibandGUID string `json:"infinibandGUID"`
}

// Manager provides interface invoke sriov nic related operations
Expand Down