From 6cd0c261b339572d824b1469e59a206155046398 Mon Sep 17 00:00:00 2001 From: Johan Euphrosine Date: Thu, 9 Oct 2014 16:47:56 -0700 Subject: [PATCH] runonce: better container state detection --- pkg/kubelet/runonce.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/runonce.go b/pkg/kubelet/runonce.go index 0053a4bb8b0..ce9c3d39fbb 100644 --- a/pkg/kubelet/runonce.go +++ b/pkg/kubelet/runonce.go @@ -117,8 +117,18 @@ func (kl *Kubelet) runPod(pod api.BoundPod) error { // isPodRunning returns true if all containers of a manifest are running. func (kl *Kubelet) isPodRunning(pod api.BoundPod, dockerContainers dockertools.DockerContainers) bool { for _, container := range pod.Spec.Containers { - if dockerContainer, found, _ := dockerContainers.FindPodContainer(GetPodFullName(&pod), pod.UID, container.Name); !found || dockerContainer.Status != "running" { - glog.Infof("container %q not found (%v) or not running: %#v", container.Name, found, dockerContainer) + dockerContainer, found, _ := dockerContainers.FindPodContainer(GetPodFullName(&pod), pod.UID, container.Name) + if !found { + glog.Infof("container %q not found", container.Name) + return false + } + inspectResult, err := kl.dockerClient.InspectContainer(dockerContainer.ID) + if err != nil { + glog.Infof("failed to inspect container %q: %v", container.Name, err) + return false + } + if !inspectResult.State.Running { + glog.Infof("container %q not running: %#v", container.Name, inspectResult.State) return false } }