runonce: better container state detection

pull/6/head
Johan Euphrosine 2014-10-09 16:47:56 -07:00
parent fa4e186e54
commit 6cd0c261b3
1 changed files with 12 additions and 2 deletions

View File

@ -117,8 +117,18 @@ func (kl *Kubelet) runPod(pod api.BoundPod) error {
// isPodRunning returns true if all containers of a manifest are running. // isPodRunning returns true if all containers of a manifest are running.
func (kl *Kubelet) isPodRunning(pod api.BoundPod, dockerContainers dockertools.DockerContainers) bool { func (kl *Kubelet) isPodRunning(pod api.BoundPod, dockerContainers dockertools.DockerContainers) bool {
for _, container := range pod.Spec.Containers { for _, container := range pod.Spec.Containers {
if dockerContainer, found, _ := dockerContainers.FindPodContainer(GetPodFullName(&pod), pod.UID, container.Name); !found || dockerContainer.Status != "running" { dockerContainer, found, _ := dockerContainers.FindPodContainer(GetPodFullName(&pod), pod.UID, container.Name)
glog.Infof("container %q not found (%v) or not running: %#v", container.Name, found, dockerContainer) 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 return false
} }
} }