mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +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 {
|
||||
return false
|
||||
}
|
||||
// Always restart container in unknown state now
|
||||
if status.State == ContainerStateUnknown {
|
||||
// Always restart container in the unknown, or in the created state.
|
||||
if status.State == ContainerStateUnknown || status.State == ContainerStateCreated {
|
||||
return true
|
||||
}
|
||||
// Check RestartPolicy for dead container
|
||||
|
@ -1210,6 +1210,13 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
|
||||
switch cs.State {
|
||||
case kubecontainer.ContainerStateRunning:
|
||||
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:
|
||||
status.State.Terminated = &v1.ContainerStateTerminated{
|
||||
ExitCode: int32(cs.ExitCode),
|
||||
|
Loading…
Reference in New Issue
Block a user