mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #1439 from jhadvig/err_handler
Handle invalid pod name
This commit is contained in:
commit
7a96ed38b3
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user