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

Enhance CNI flexibility to read and write deviceInfo by removing the deviceID restriction #1275

Closed
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
10 changes: 10 additions & 0 deletions pkg/multus/multus.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,16 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
if err != nil {
logging.Debugf("CmdAdd: CopyDeviceInfoForCNIFromDP returned an error - err=%v", err)
}
} else if delegate.Conf.Capabilities["CNIDeviceInfoFile"] {
devInfo := &nettypes.DeviceInfo{}
err = nadutils.SaveDeviceInfoForCNI(cniDeviceInfoPath, devInfo)
// For CNIs with Capabilities["CNIDeviceInfoFile"] set to true, a deviceinfofile is
// created to conveniently pass the CNIDeviceInfoFile to the CNI. This allows the CNI
// to flexibly read and write DeviceInfo in annotations, not limited to CNIs with
// deviceID present.
if err != nil {
logging.Debugf("CmdAdd: SaveDeviceInfoForCNI returned an error - err=%v", err)
}
}

// We collect the delegate netName for the cachefile name as well as following errors
Expand Down
5 changes: 5 additions & 0 deletions pkg/types/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ func delegateRuntimeConfig(containerID string, delegate *DelegateNetConf, rc *Ru
autoDeviceInfo := fmt.Sprintf("%s-%s_%s", delegate.Name, containerID, ifName)
delegateRc.CNIDeviceInfoFile = nadutils.GetCNIDeviceInfoPath(autoDeviceInfo)
logging.Debugf("Adding auto-generated CNIDeviceInfoFile: %s", delegateRc.CNIDeviceInfoFile)
} else if delegate.Conf.Capabilities["CNIDeviceInfoFile"] {
// generater empty CNIDeviceInfoFile filepath
autoDeviceInfo := fmt.Sprintf("%s-%s_%s", delegate.Name, containerID, ifName)
delegateRc.CNIDeviceInfoFile = nadutils.GetCNIDeviceInfoPath(autoDeviceInfo)
logging.Debugf("CNIDeviceInfoFile is true, Adding auto-generated empty CNIDeviceInfoFile: %s", delegateRc.CNIDeviceInfoFile)
}
} else {
delegateRc = rc
Expand Down