From b48834e198edec6b8ce45b89c6f322da44679512 Mon Sep 17 00:00:00 2001 From: Dawn Chen Date: Wed, 10 Sep 2014 13:20:29 -0700 Subject: [PATCH] Fix PodInfo to include last terminated container info when calling GetPodInfo based on name and UUID. With this fix, if some of containers are dead, the pod status will stay as Running, not reset back to Waiting. --- pkg/kubelet/docker.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/docker.go b/pkg/kubelet/docker.go index cc701ed8848..79429544454 100644 --- a/pkg/kubelet/docker.go +++ b/pkg/kubelet/docker.go @@ -180,14 +180,14 @@ func getRecentDockerContainersWithNameAndUUID(client DockerInterface, podFullNam return result, nil } -// ErrNoContainersInPod is returned when there are no running containers for a given pod +// ErrNoContainersInPod is returned when there are no containers for a given pod var ErrNoContainersInPod = errors.New("no containers exist for this pod") // GetDockerPodInfo returns docker info for all containers in the pod/manifest. func getDockerPodInfo(client DockerInterface, podFullName, uuid string) (api.PodInfo, error) { info := api.PodInfo{} - containers, err := client.ListContainers(docker.ListContainersOptions{}) + containers, err := client.ListContainers(docker.ListContainersOptions{All: true}) if err != nil { return nil, err } @@ -200,6 +200,11 @@ func getDockerPodInfo(client DockerInterface, podFullName, uuid string) (api.Pod if uuid != "" && dockerUUID != uuid { continue } + // We assume docker return us a list of containers in time order + if _, ok := info[dockerContainerName]; ok { + continue + } + inspectResult, err := client.InspectContainer(value.ID) if err != nil { return nil, err