mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Make CPU manager release allocated CPUs when container enters completed phase.
This commit is contained in:
parent
a63e3deec3
commit
e2e356964a
@ -474,6 +474,17 @@ func (m *kubeGenericRuntimeManager) computePodActions(pod *v1.Pod, podStatus *ku
|
|||||||
// check the status of containers.
|
// check the status of containers.
|
||||||
for idx, container := range pod.Spec.Containers {
|
for idx, container := range pod.Spec.Containers {
|
||||||
containerStatus := podStatus.FindContainerStatusByName(container.Name)
|
containerStatus := podStatus.FindContainerStatusByName(container.Name)
|
||||||
|
|
||||||
|
// Call internal container post-stop lifecycle hook for any non-running container so that any
|
||||||
|
// allocated cpus are released immediately. If the container is restarted, cpus will be re-allocated
|
||||||
|
// to it.
|
||||||
|
if containerStatus != nil && containerStatus.State != kubecontainer.ContainerStateRunning {
|
||||||
|
if err := m.internalLifecycle.PostStopContainer(containerStatus.ID.ID); err != nil {
|
||||||
|
glog.Errorf("internal container post-stop lifecycle hook failed for container %v in pod %v with error %v",
|
||||||
|
container.Name, pod.Name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// If container does not exist, or is not running, check whether we
|
// If container does not exist, or is not running, check whether we
|
||||||
// need to restart it.
|
// need to restart it.
|
||||||
if containerStatus == nil || containerStatus.State != kubecontainer.ContainerStateRunning {
|
if containerStatus == nil || containerStatus.State != kubecontainer.ContainerStateRunning {
|
||||||
|
Loading…
Reference in New Issue
Block a user