Fix bug in TopologManager RemoveContainer()

Previously, we unconditionally removed *all* topology hints from a pod
whenever just one container was being removed. This commit makes it so
we only remove the hints for the single container being removed, and
then conditionally remove the pod from the podTopologyHints[podUID] when
no containers left in it.
This commit is contained in:
Kevin Klues 2020-02-02 17:22:06 +00:00
parent 7a01cdcaea
commit 95a3ac447f

View File

@ -194,10 +194,17 @@ func (m *manager) AddContainer(pod *v1.Pod, containerID string) error {
}
func (m *manager) RemoveContainer(containerID string) error {
klog.Infof("[topologymanager] RemoveContainer - Container ID: %v", containerID)
podUIDString := m.podMap[containerID]
delete(m.podTopologyHints, podUIDString)
delete(m.podMap, containerID)
klog.Infof("[topologymanager] RemoveContainer - Container ID: %v podTopologyHints: %v", containerID, m.podTopologyHints)
if _, exists := m.podTopologyHints[podUIDString]; exists {
delete(m.podTopologyHints[podUIDString], containerID)
if len(m.podTopologyHints[podUIDString]) == 0 {
delete(m.podTopologyHints, podUIDString)
}
}
return nil
}