From 7c75f5c55126c49382d49db6eeed3d301ef0756e Mon Sep 17 00:00:00 2001 From: Yu-Ju Hong Date: Wed, 17 May 2017 10:49:03 -0700 Subject: [PATCH] kuberuntime: report StartedAt for exited containers --- pkg/kubelet/kuberuntime/kuberuntime_container.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/kuberuntime/kuberuntime_container.go b/pkg/kubelet/kuberuntime/kuberuntime_container.go index 18ae3a38fc2..d01b91e8ba7 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_container.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_container.go @@ -402,9 +402,12 @@ func (m *kubeGenericRuntimeManager) getPodContainerStatuses(uid kubetypes.UID, n CreatedAt: time.Unix(0, status.CreatedAt), } - if c.State == runtimeapi.ContainerState_CONTAINER_RUNNING { + if c.State != runtimeapi.ContainerState_CONTAINER_CREATED { + // If container is not in the created state, we have tried and + // started the container. Set the StartedAt time. cStatus.StartedAt = time.Unix(0, status.StartedAt) - } else { + } + if c.State == runtimeapi.ContainerState_CONTAINER_EXITED { cStatus.Reason = status.Reason cStatus.Message = status.Message cStatus.ExitCode = int(status.ExitCode)