Merge pull request #26208 from freehan/kubenetteardownfix

do not return error if TearDownPod is called twice
This commit is contained in:
Alex Robinson 2016-05-27 09:59:03 -07:00
commit 07d9dff83c

View File

@ -370,7 +370,8 @@ func (plugin *kubenetNetworkPlugin) TearDownPod(namespace string, name string, i
}
// no cached CIDR is Ok during teardown
if cidr, ok := plugin.podCIDRs[id]; ok {
cidr, hasCIDR := plugin.podCIDRs[id]
if hasCIDR {
glog.V(5).Infof("Removing pod CIDR %s from shaper", cidr)
// shaper wants /32
if addr, _, err := net.ParseCIDR(cidr); err != nil {
@ -380,6 +381,11 @@ func (plugin *kubenetNetworkPlugin) TearDownPod(namespace string, name string, i
}
}
if err := plugin.delContainerFromNetwork(plugin.netConfig, network.DefaultInterfaceName, namespace, name, id); err != nil {
// This is to prevent returning error when TearDownPod is called twice on the same pod. This helps to reduce event pollution.
if !hasCIDR {
glog.Warningf("Failed to delete container from kubenet: %v", err)
return nil
}
return err
}
delete(plugin.podCIDRs, id)