Commit fb1c55aa authored by Yifan Gu's avatar Yifan Gu

kubelet/container: Add GetContainerLogs to runtime interface.

parent a4316aa6
...@@ -72,6 +72,11 @@ type Runtime interface { ...@@ -72,6 +72,11 @@ type Runtime interface {
Pull(image string) Pull(image string)
// IsImagePresent checks whether the container image is already in the local storage. // IsImagePresent checks whether the container image is already in the local storage.
IsImagePresent(image string) (bool, error) IsImagePresent(image string) (bool, error)
// GetContainerLogs returns logs of a specific container. By
// default, it returns a snapshot of the container log. Set 'follow' to true to
// stream the log. Set 'follow' to false and specify the number of lines (e.g.
// "100" or "all") to tail the log.
GetContainerLogs(containerID, tail string, follow bool, stdout, stderr io.Writer) (err error)
} }
// Pod is a group of containers, with the status of the pod. // Pod is a group of containers, with the status of the pod.
......
...@@ -171,12 +171,12 @@ func (sc *stringCache) Get(uid types.UID, name string) (string, bool) { ...@@ -171,12 +171,12 @@ func (sc *stringCache) Get(uid types.UID, name string) (string, bool) {
} }
} }
// GetKubeletDockerContainerLogs returns logs of a specific container. By // GetContainerLogs returns logs of a specific container. By
// default, it returns a snapshot of the container log. Set |follow| to true to // default, it returns a snapshot of the container log. Set 'follow' to true to
// stream the log. Set |follow| to false and specify the number of lines (e.g. // stream the log. Set 'follow' to false and specify the number of lines (e.g.
// "100" or "all") to tail the log. // "100" or "all") to tail the log.
// TODO: Make 'RawTerminal' option flagable. // TODO: Make 'RawTerminal' option flagable.
func (dm *DockerManager) GetKubeletDockerContainerLogs(containerID, tail string, follow bool, stdout, stderr io.Writer) (err error) { func (dm *DockerManager) GetContainerLogs(containerID, tail string, follow bool, stdout, stderr io.Writer) (err error) {
opts := docker.LogsOptions{ opts := docker.LogsOptions{
Container: containerID, Container: containerID,
Stdout: true, Stdout: true,
......
...@@ -1655,7 +1655,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri ...@@ -1655,7 +1655,7 @@ func (kl *Kubelet) GetKubeletContainerLogs(podFullName, containerName, tail stri
// waiting state. // waiting state.
return err return err
} }
return kl.containerManager.GetKubeletDockerContainerLogs(dockerContainerID, tail, follow, stdout, stderr) return kl.containerManager.GetContainerLogs(dockerContainerID, tail, follow, stdout, stderr)
} }
// GetHostname Returns the hostname as the kubelet sees it. // GetHostname Returns the hostname as the kubelet sees it.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment