mirror of
https://github.com/k8snetworkplumbingwg/multus-cni.git
synced 2025-09-16 14:33:59 +00:00
Merge pull request #644 from s1061123/dev/cleanup-dev-info
Skip to call device-info related function if not required
This commit is contained in:
@@ -584,7 +584,7 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
|
||||
for idx, delegate := range n.Delegates {
|
||||
ifName := getIfname(delegate, args.IfName, idx)
|
||||
rt, cniDeviceInfoPath := types.CreateCNIRuntimeConf(args, k8sArgs, ifName, n.RuntimeConfig, delegate)
|
||||
if cniDeviceInfoPath != "" {
|
||||
if cniDeviceInfoPath != "" && delegate.ResourceName != "" && delegate.DeviceID != "" {
|
||||
err = nadutils.CopyDeviceInfoForCNIFromDP(cniDeviceInfoPath, delegate.ResourceName, delegate.DeviceID)
|
||||
// Even if the filename is set, file may not be present. Ignore error,
|
||||
// but log and in the future may need to filter on specific errors.
|
||||
|
@@ -188,13 +188,15 @@ func CreateCNIRuntimeConf(args *skel.CmdArgs, k8sArgs *K8sArgs, ifName string, r
|
||||
|
||||
if delegate != nil {
|
||||
delegateRc = mergeCNIRuntimeConfig(rc, delegate)
|
||||
if delegateRc.CNIDeviceInfoFile != "" {
|
||||
logging.Debugf("Warning: Existing value of CNIDeviceInfoFile will be overwritten %s", delegateRc.CNIDeviceInfoFile)
|
||||
if delegateRc.DeviceID != "" {
|
||||
if delegateRc.CNIDeviceInfoFile != "" {
|
||||
logging.Debugf("Warning: Existing value of CNIDeviceInfoFile will be overwritten %s", delegateRc.CNIDeviceInfoFile)
|
||||
}
|
||||
autoDeviceInfo := fmt.Sprintf("%s-%s_%s", delegate.Name, args.ContainerID, ifName)
|
||||
delegateRc.CNIDeviceInfoFile = nadutils.GetCNIDeviceInfoPath(autoDeviceInfo)
|
||||
cniDeviceInfoFile = delegateRc.CNIDeviceInfoFile
|
||||
logging.Debugf("Adding auto-generated CNIDeviceInfoFile: %s", delegateRc.CNIDeviceInfoFile)
|
||||
}
|
||||
autoDeviceInfo := fmt.Sprintf("%s-%s_%s", delegate.Name, args.ContainerID, ifName)
|
||||
delegateRc.CNIDeviceInfoFile = nadutils.GetCNIDeviceInfoPath(autoDeviceInfo)
|
||||
cniDeviceInfoFile = delegateRc.CNIDeviceInfoFile
|
||||
logging.Debugf("Adding auto-generated CNIDeviceInfoFile: %s", delegateRc.CNIDeviceInfoFile)
|
||||
} else {
|
||||
delegateRc = rc
|
||||
}
|
||||
|
Reference in New Issue
Block a user