kubelet: handle containers in the "created" state

This commit is contained in:
Yu-Ju Hong 2017-02-13 21:09:44 -08:00
parent b1e0d0ee5e
commit 9fa1ad29fd
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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),