mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #35309 from yujuhong/fix_restarts
Automatic merge from submit-queue CRI: Handle container/sandbox restarts for pod with RestartPolicy == … If all sandbox and containers are dead in a pod, and the restart policy is "Never", kubelet should not try to recreate all of them.
This commit is contained in:
commit
d20dda0c06
@ -471,13 +471,6 @@ func (m *kubeGenericRuntimeManager) computePodContainerChanges(pod *api.Pod, pod
|
|||||||
|
|
||||||
// check the status of containers.
|
// check the status of containers.
|
||||||
for index, container := range pod.Spec.Containers {
|
for index, container := range pod.Spec.Containers {
|
||||||
if sandboxChanged {
|
|
||||||
message := fmt.Sprintf("Container %+v's pod sandbox is dead, the container will be recreated.", container)
|
|
||||||
glog.Info(message)
|
|
||||||
changes.ContainersToStart[index] = message
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
containerStatus := podStatus.FindContainerStatusByName(container.Name)
|
containerStatus := podStatus.FindContainerStatusByName(container.Name)
|
||||||
if containerStatus == nil || containerStatus.State != kubecontainer.ContainerStateRunning {
|
if containerStatus == nil || containerStatus.State != kubecontainer.ContainerStateRunning {
|
||||||
if kubecontainer.ShouldContainerBeRestarted(&container, pod, podStatus) {
|
if kubecontainer.ShouldContainerBeRestarted(&container, pod, podStatus) {
|
||||||
@ -487,6 +480,14 @@ func (m *kubeGenericRuntimeManager) computePodContainerChanges(pod *api.Pod, pod
|
|||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if sandboxChanged {
|
||||||
|
if pod.Spec.RestartPolicy != api.RestartPolicyNever {
|
||||||
|
message := fmt.Sprintf("Container %+v's pod sandbox is dead, the container will be recreated.", container)
|
||||||
|
glog.Info(message)
|
||||||
|
changes.ContainersToStart[index] = message
|
||||||
|
}
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if initFailed {
|
if initFailed {
|
||||||
// Initialization failed and Container exists.
|
// Initialization failed and Container exists.
|
||||||
|
Loading…
Reference in New Issue
Block a user