Merge pull request #1439 from jhadvig/err_handler

Handle invalid pod name
This commit is contained in:
Tim Hockin 2014-09-25 15:00:47 -07:00
commit 7a96ed38b3
2 changed files with 7 additions and 4 deletions

View File

@ -720,15 +720,19 @@ func (kl *Kubelet) statsFromContainerPath(containerPath string, req *info.Contai
}
// GetKubeletContainerLogs returns logs from the container
// The second parameter of GetPodInfo and FindPodContainer methods represents pod UUID, which is allowed to be blank
func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
_, err := kl.GetPodInfo(podFullName, "")
if err == dockertools.ErrNoContainersInPod {
return fmt.Errorf("Pod not found (%s)\n", podFullName)
}
dockerContainers, err := dockertools.GetKubeletDockerContainers(kl.dockerClient)
if err != nil {
return err
}
var uuid string
dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, uuid, containerName)
dockerContainer, found, _ := dockerContainers.FindPodContainer(podFullName, "", containerName)
if !found {
return fmt.Errorf("container not found (%s)\n", containerName)
return fmt.Errorf("Container not found (%s)\n", containerName)
}
return dockertools.GetKubeletDockerContainerLogs(kl.dockerClient, dockerContainer.ID, tail, follow, stdout, stderr)
}

View File

@ -366,7 +366,6 @@ func TestContainerLogs(t *testing.T) {
expectedContainerName := "baz"
expectedTail := ""
expectedFollow := false
// expected := api.Container{"goodpod": docker.Container{ID: "myContainerID"}}
fw.fakeKubelet.containerLogsFunc = func(podFullName, containerName, tail string, follow bool, stdout, stderr io.Writer) error {
if podFullName != expectedPodName {
t.Errorf("expected %s, got %s", expectedPodName, podFullName)