The cachefile name should be the delegate configuration name (#841)

It was previously using the net-attach-def name, which doesn't align with the cache file. Causing default-route selection to not succeed.
This commit is contained in:
Doug Smith 2022-05-06 11:06:37 -04:00 committed by GitHub
parent ecc1482d50
commit dcbc215b93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -617,14 +617,14 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
}
}
netName := ""
// We collect the delegate netName for the cachefile name as well as following errors
netName := delegate.Conf.Name
if netName == "" {
netName = delegate.ConfList.Name
}
tmpResult, err = delegateAdd(exec, kubeClient, pod, delegate, rt, n)
if err != nil {
// If the add failed, tear down all networks we already added
netName = delegate.Conf.Name
if netName == "" {
netName = delegate.ConfList.Name
}
// Ignore errors; DEL must be idempotent anyway
_ = delPlugins(exec, nil, args, k8sArgs, n.Delegates, idx, n.RuntimeConfig, n)
return nil, cmdPluginErr(k8sArgs, netName, "error adding container to network %q: %v", netName, err)
@ -666,10 +666,6 @@ func CmdAdd(args *skel.CmdArgs, exec invoke.Exec, kubeClient *k8s.ClientInfo) (c
}
}
// Remove namespace from delegate.Name for Add/Del CNI cache
nameSlice := strings.Split(delegate.Name, "/")
netName = nameSlice[len(nameSlice)-1]
// Remove gateway if `default-route` network selection is specified
if deleteV4gateway || deleteV6gateway {
err = netutils.DeleteDefaultGW(args, ifName)