mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Check pod RestartPolicy before restarting unhealthy containers
This commit is contained in:
parent
7ba48583fa
commit
f67879eac7
@ -1724,9 +1724,11 @@ func (dm *DockerManager) computePodContainerChanges(pod *api.Pod, runningPod kub
|
|||||||
containersToKeep[containerID] = index
|
containersToKeep[containerID] = index
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if pod.Spec.RestartPolicy != api.RestartPolicyNever {
|
||||||
glog.Infof("pod %q container %q is unhealthy (probe result: %v), it will be killed and re-created.", podFullName, container.Name, result)
|
glog.Infof("pod %q container %q is unhealthy (probe result: %v), it will be killed and re-created.", podFullName, container.Name, result)
|
||||||
containersToStart[index] = empty{}
|
containersToStart[index] = empty{}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// After the loop one of the following should be true:
|
// After the loop one of the following should be true:
|
||||||
// - createPodInfraContainer is true and containersToKeep is empty.
|
// - createPodInfraContainer is true and containersToKeep is empty.
|
||||||
|
@ -1022,7 +1022,7 @@ func (r *runtime) SyncPod(pod *api.Pod, runningPod kubecontainer.Pod, podStatus
|
|||||||
|
|
||||||
result, err := r.prober.ProbeLiveness(pod, podStatus, container, string(c.ID), c.Created)
|
result, err := r.prober.ProbeLiveness(pod, podStatus, container, string(c.ID), c.Created)
|
||||||
// TODO(vmarmol): examine this logic.
|
// TODO(vmarmol): examine this logic.
|
||||||
if err == nil && result != probe.Success {
|
if err == nil && result != probe.Success && pod.Spec.RestartPolicy != api.RestartPolicyNever {
|
||||||
glog.Infof("Pod %q container %q is unhealthy (probe result: %v), it will be killed and re-created.", podFullName, container.Name, result)
|
glog.Infof("Pod %q container %q is unhealthy (probe result: %v), it will be killed and re-created.", podFullName, container.Name, result)
|
||||||
restartPod = true
|
restartPod = true
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user