From 2970f2220ff71717181088f7613b75c27204d27a Mon Sep 17 00:00:00 2001 From: Angus Salkeld Date: Tue, 17 May 2016 13:19:40 +1000 Subject: [PATCH] Use docker containerInfo.LogPath and not manually constructed path Since the containerInfo has the LogPath in it, let's use that and not manually construct the path ourselves. This also makes the code less prone to breaking if docker change this path. Fixes #23695 --- pkg/kubelet/dockertools/manager.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/kubelet/dockertools/manager.go b/pkg/kubelet/dockertools/manager.go index fea46a5a52b..1442e2b1497 100644 --- a/pkg/kubelet/dockertools/manager.go +++ b/pkg/kubelet/dockertools/manager.go @@ -1485,22 +1485,22 @@ func (dm *DockerManager) runContainerInPod(pod *api.Pod, container *api.Containe } } + // Container information is used in adjusting OOM scores, adding ndots and getting the logPath. + containerInfo, err := dm.client.InspectContainer(id.ID) + if err != nil { + return kubecontainer.ContainerID{}, fmt.Errorf("InspectContainer: %v", err) + } + // Create a symbolic link to the Docker container log file using a name which captures the // full pod name, the container name and the Docker container ID. Cluster level logging will // capture these symbolic filenames which can be used for search terms in Elasticsearch or for // labels for Cloud Logging. - containerLogFile := path.Join(dm.dockerRoot, "containers", id.ID, fmt.Sprintf("%s-json.log", id.ID)) + containerLogFile := containerInfo.LogPath symlinkFile := LogSymlink(dm.containerLogsDir, kubecontainer.GetPodFullName(pod), container.Name, id.ID) if err = dm.os.Symlink(containerLogFile, symlinkFile); err != nil { glog.Errorf("Failed to create symbolic link to the log file of pod %q container %q: %v", format.Pod(pod), container.Name, err) } - // Container information is used in adjusting OOM scores and adding ndots. - containerInfo, err := dm.client.InspectContainer(id.ID) - if err != nil { - return kubecontainer.ContainerID{}, fmt.Errorf("InspectContainer: %v", err) - } - // Check if current docker version is higher than 1.10. Otherwise, we have to apply OOMScoreAdj instead of using docker API. // TODO: Remove this logic after we stop supporting docker version < 1.10. if err = dm.applyOOMScoreAdjIfNeeded(pod, container, containerInfo); err != nil {