do not return error if TearDownPod is called twice

This commit is contained in:
Minhan Xia 2016-05-24 14:18:28 -07:00
parent 0c20ae7e90
commit 0834dc489a

View File

@ -339,7 +339,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 {
@ -349,6 +350,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)