netstat: On teardown, check VMI UID as prefix
The condition that checks if a cache entry should be removed or not was
using "contains".
Change it to be more accurate by just checking it is at the prefix.
@@ -50,7 +50,7 @@ func NewNetStat(ifaceCacheFactory cache.InterfaceCacheFactory) *NetStat {
func (c *NetStat) Teardown(vmi *v1.VirtualMachineInstance) {
c.podInterfaceVolatileCache.Range(func(key, value interface{}) bool {
- if strings.Contains(key.(string), string(vmi.UID)) {
+ if strings.HasPrefix(key.(string), string(vmi.UID)) {
c.podInterfaceVolatileCache.Delete(key)
}
return true
