mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 11:21:47 +00:00
Merge pull request #109103 from Dingshujie/fix_memory_leak
cpu/memory manager containerMap memory leak
This commit is contained in:
commit
dbf2f1d833
@ -69,3 +69,10 @@ func (cm ContainerMap) GetContainerRef(containerID string) (string, string, erro
|
||||
}
|
||||
return cm[containerID].podUID, cm[containerID].containerName, nil
|
||||
}
|
||||
|
||||
// Visit invoke visitor function to walks all of the entries in the container map
|
||||
func (cm ContainerMap) Visit(visitor func(podUID, containerName, containerID string)) {
|
||||
for k, v := range cm {
|
||||
visitor(v.podUID, v.containerName, k)
|
||||
}
|
||||
}
|
||||
|
@ -388,6 +388,16 @@ func (m *manager) removeStaleState() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m.containerMap.Visit(func(podUID, containerName, containerID string) {
|
||||
if _, ok := activeContainers[podUID][containerName]; !ok {
|
||||
klog.ErrorS(nil, "RemoveStaleState: removing container", "podUID", podUID, "containerName", containerName)
|
||||
err := m.policyRemoveContainerByRef(podUID, containerName)
|
||||
if err != nil {
|
||||
klog.ErrorS(err, "RemoveStaleState: failed to remove container", "podUID", podUID, "containerName", containerName)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m *manager) reconcileState() (success []reconciledContainer, failure []reconciledContainer) {
|
||||
|
@ -339,6 +339,13 @@ func (m *manager) removeStaleState() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m.containerMap.Visit(func(podUID, containerName, containerID string) {
|
||||
if _, ok := activeContainers[podUID][containerName]; !ok {
|
||||
klog.InfoS("RemoveStaleState removing state", "podUID", podUID, "containerName", containerName)
|
||||
m.policyRemoveContainerByRef(podUID, containerName)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func (m *manager) policyRemoveContainerByRef(podUID string, containerName string) {
|
||||
|
Loading…
Reference in New Issue
Block a user