Merge pull request #5657 from AlbanBedel/network-name-fix

Fix the pod name passed to cni
This commit is contained in:
OpenShift Merge Robot 2020-04-17 11:25:19 -04:00 committed by GitHub
commit 454fc9fecd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -101,7 +101,19 @@ func (r *Runtime) configureNetNS(ctr *Container, ctrNS ns.NetNS) ([]*cnitypes.Re
requestedMAC = ctr.config.StaticMAC requestedMAC = ctr.config.StaticMAC
} }
podNetwork := r.getPodNetwork(ctr.ID(), ctr.Name(), ctrNS.Path(), ctr.config.Networks, ctr.config.PortMappings, requestedIP, requestedMAC) // If we are in a pod use the pod name for the network, otherwise the container name
var podName string
if ctr.PodID() != "" {
pod, err := r.GetPod(ctr.PodID())
if err == nil {
podName = pod.Name()
}
}
if podName == "" {
podName = ctr.Name()
}
podNetwork := r.getPodNetwork(ctr.ID(), podName, ctrNS.Path(), ctr.config.Networks, ctr.config.PortMappings, requestedIP, requestedMAC)
results, err := r.netPlugin.SetUpPod(podNetwork) results, err := r.netPlugin.SetUpPod(podNetwork)
if err != nil { if err != nil {