mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 05:27:21 +00:00
Merge pull request #97427 from klueska/upstream-fix-cpumanager-race
Fix bug in CPUManager with race on container map access
This commit is contained in:
commit
4dc3a42712
@ -402,6 +402,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m.Lock()
|
||||||
if cstatus.State.Terminated != nil {
|
if cstatus.State.Terminated != nil {
|
||||||
// The container is terminated but we can't call m.RemoveContainer()
|
// The container is terminated but we can't call m.RemoveContainer()
|
||||||
// here because it could remove the allocated cpuset for the container
|
// here because it could remove the allocated cpuset for the container
|
||||||
@ -412,6 +413,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
if err == nil {
|
if err == nil {
|
||||||
klog.Warningf("[cpumanager] reconcileState: ignoring terminated container (pod: %s, container id: %s)", pod.Name, containerID)
|
klog.Warningf("[cpumanager] reconcileState: ignoring terminated container (pod: %s, container id: %s)", pod.Name, containerID)
|
||||||
}
|
}
|
||||||
|
m.Unlock()
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,6 +421,7 @@ func (m *manager) reconcileState() (success []reconciledContainer, failure []rec
|
|||||||
// Idempotently add it to the containerMap incase it is missing.
|
// Idempotently add it to the containerMap incase it is missing.
|
||||||
// This can happen after a kubelet restart, for example.
|
// This can happen after a kubelet restart, for example.
|
||||||
m.containerMap.Add(string(pod.UID), container.Name, containerID)
|
m.containerMap.Add(string(pod.UID), container.Name, containerID)
|
||||||
|
m.Unlock()
|
||||||
|
|
||||||
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)
|
cset := m.state.GetCPUSetOrDefault(string(pod.UID), container.Name)
|
||||||
if cset.IsEmpty() {
|
if cset.IsEmpty() {
|
||||||
|
Loading…
Reference in New Issue
Block a user