mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
kubelet: handle containers in the "created" state
This commit is contained in:
parent
b1e0d0ee5e
commit
9fa1ad29fd
@ -72,8 +72,8 @@ func ShouldContainerBeRestarted(container *v1.Container, pod *v1.Pod, podStatus
|
|||||||
if status.State == ContainerStateRunning {
|
if status.State == ContainerStateRunning {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Always restart container in unknown state now
|
// Always restart container in the unknown, or in the created state.
|
||||||
if status.State == ContainerStateUnknown {
|
if status.State == ContainerStateUnknown || status.State == ContainerStateCreated {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
// Check RestartPolicy for dead container
|
// Check RestartPolicy for dead container
|
||||||
|
@ -1210,6 +1210,13 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
|||||||
switch cs.State {
|
switch cs.State {
|
||||||
case kubecontainer.ContainerStateRunning:
|
case kubecontainer.ContainerStateRunning:
|
||||||
status.State.Running = &v1.ContainerStateRunning{StartedAt: metav1.NewTime(cs.StartedAt)}
|
status.State.Running = &v1.ContainerStateRunning{StartedAt: metav1.NewTime(cs.StartedAt)}
|
||||||
|
case kubecontainer.ContainerStateCreated:
|
||||||
|
// Treat containers in the "created" state as if they are exited.
|
||||||
|
// The pod workers are supposed start all containers it creates in
|
||||||
|
// one sync (syncPod) iteration. There should not be any normal
|
||||||
|
// "created" containers when the pod worker generates the status at
|
||||||
|
// the beginning of a sync iteration.
|
||||||
|
fallthrough
|
||||||
case kubecontainer.ContainerStateExited:
|
case kubecontainer.ContainerStateExited:
|
||||||
status.State.Terminated = &v1.ContainerStateTerminated{
|
status.State.Terminated = &v1.ContainerStateTerminated{
|
||||||
ExitCode: int32(cs.ExitCode),
|
ExitCode: int32(cs.ExitCode),
|
||||||
|
Loading…
Reference in New Issue
Block a user