Change:
The should be updated to check CRI log paths.
Issues go stale after 90d of inactivity. Mark the issue as fresh with . Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle stale
Stale issues rot after 30d of inactivity. Mark the issue as fresh with . Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with . Send feedback to sig-testing, kubernetes/test-infra and/or . /lifecycle rotten
May I try to help with this?
GitHub didn't allow me to assign the following users: fatsheep9146. Note that only and repo collaborators can be assigned. For more information please see <detailsIn response to : /assign Instructions for interacting with me using PR comments are available . If you have questions or suggestions related to my behavior, please file an issue against the repository. </details

Discussion:
package e2e_node import ( <ins> . "github.com/onsi/ginkgo" </ins> "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" <ins> "k8s.io/apimachinery/pkg/util/uuid" </ins> "k8s.io/kubernetes/pkg/kubelet" kubecontainer "k8s.io/kubernetes/pkg/kubelet/container" "k8s.io/kubernetes/test/e2e/framework" <del> . "github.com/onsi/ginkgo" </del> ) const ( <del> logString = "This is the expected log content of this node e2e test" logPodName    = "logger-pod" logContName   = "logger-container" checkPodName  = "checker-pod" checkContName = "checker-container" </del> <ins> logString        = "This is the expected log content of this node e2e test" logContainerName = "logger" </ins> ) var _ = framework.KubeDescribe("ContainerLogPath [NodeConformance]", func() { f := framework.NewDefaultFramework("kubelet-container-log-path") <ins> var podClient *framework.PodClient </ins> Describe("Pod with a container", func() { Context("printed log to stdout", func() { <del> BeforeEach(func() { if framework.TestContext.ContainerRuntime == "docker" { // Container Log Path support requires JSON logging driver. // It does not work when Docker daemon is logging to journald. d, err := getDockerLoggingDriver() framework.ExpectNoError(err) if d != "json-file" { framework.Skipf("Skipping because Docker daemon is using a logging driver other than "json-file": %s", d) } // Even if JSON logging is in use, this test fails if SELinux support // is enabled, since the isolation provided by the SELinux policy // prevents processes running inside Docker containers (under SELinux // type svirt_lxc_net_t) from accessing the log files which are owned // by Docker (and labeled with the container_var_lib_t type.) // // Therefore, let's also skip this test when running with SELinux // support enabled. e, err := isDockerSELinuxSupportEnabled() framework.ExpectNoError(err) if e { framework.Skipf("Skipping because Docker daemon is running with SELinux support enabled") } } }) It("should print log to correct log path", func() { podClient := f.PodClient() ns := f.Namespace.Name logDirVolumeName := "log-dir-vol" logDir := kubelet.ContainerLogsDir logPod := &v1.Pod{ </del> <ins> makeLogPod := func(podName, log string) *v1.Pod { return &v1.Pod{ </ins> ObjectMeta: metav1.ObjectMeta{ <del> Name: logPodName, </del> <ins> Name: podName, </ins> }, Spec: v1.PodSpec{ // this pod is expected to exit successfully

Containers: []v1.Container{ { Image:   busyboxImage, <del> Name:    logContName, Command: []string{"sh", "-c", "echo " + logString}, </del> <ins> Name:    logContainerName, Command: []string{"sh", "-c", "echo " + log}, </ins> }, }, }, } <ins> } </ins> <del> podClient.Create(logPod) err := framework.WaitForPodSuccessInNamespace(f.ClientSet, logPodName, ns) framework.ExpectNoError(err, "Failed waiting for pod: %s to enter success state", logPodName) // get containerID from created Pod createdLogPod, err := podClient.Get(logPodName, metav1.GetOptions{}) logConID := kubecontainer.ParseContainerID(createdLogPod.Status.ContainerStatuses[0].ContainerID) framework.ExpectNoError(err, "Failed to get pod: %s", logPodName) expectedlogFile := logDir + "/" + logPodName + "_" + ns + "_" + logContName + "-" + logConID.ID + ".log" </del> <ins> makeLogCheckPod := func(podName, log, expectedLogPath string) *v1.Pod { </ins> hostPathType := new(v1.HostPathType) *hostPathType = v1.HostPathType(string(v1.HostPathFileOrCreate)) <del> checkPod := &v1.Pod{ </del> <ins> return &v1.Pod{ </ins> ObjectMeta: metav1.ObjectMeta{ <del> Name: checkPodName, </del> <ins> Name: podName, </ins> }, Spec: v1.PodSpec{ // this pod is expected to exit successfully

Containers: []v1.Container{ { Image: busyboxImage, <del> Name:  checkContName, </del> <ins> Name:  podName, </ins> // If we find expected log file and contains right content, exit 0 // else, keep checking until test timeout <del> Command: []string{"sh", "-c", "while true; do if [ -e " + expectedlogFile + " ] && grep -q " + logString + " " + expectedlogFile + "; then exit 0; fi; sleep 1; done"}, </del> <ins> Command: []string{"sh", "-c", "while true; do if [ -e " + expectedLogPath + " ] && grep -q " + log + " " + expectedLogPath + "; then exit 0; fi; sleep 1; done"}, </ins> VolumeMounts: []v1.VolumeMount{ { <del> Name: logDirVolumeName, </del> <ins> Name: "logdir", </ins> // mount ContainerLogsDir to the same path in container <del> MountPath: expectedlogFile, </del> <ins> MountPath: expectedLogPath, </ins> ReadOnly:  true, }, },

}, Volumes: []v1.Volume{ { <del> Name: logDirVolumeName, </del> <ins> Name: "logdir", </ins> VolumeSource: v1.VolumeSource{ HostPath: &v1.HostPathVolumeSource{ <del> Path: expectedlogFile, </del> <ins> Path: expectedLogPath, </ins> Type: hostPathType, }, },

}, }, } <ins> } createAndWaitPod := func(pod *v1.Pod) error { podClient.Create(pod) return framework.WaitForPodSuccessInNamespace(f.ClientSet, pod.Name, f.Namespace.Name) } var logPodName string BeforeEach(func() { if framework.TestContext.ContainerRuntime == "docker" { // Container Log Path support requires JSON logging driver. // It does not work when Docker daemon is logging to journald. d, err := getDockerLoggingDriver() framework.ExpectNoError(err) if d != "json-file" { framework.Skipf("Skipping because Docker daemon is using a logging driver other than "json-file": %s", d) } // Even if JSON logging is in use, this test fails if SELinux support // is enabled, since the isolation provided by the SELinux policy // prevents processes running inside Docker containers (under SELinux // type svirt_lxc_net_t) from accessing the log files which are owned // by Docker (and labeled with the container_var_lib_t type.) // // Therefore, let's also skip this test when running with SELinux // support enabled. e, err := isDockerSELinuxSupportEnabled() framework.ExpectNoError(err) if e { framework.Skipf("Skipping because Docker daemon is running with SELinux support enabled") } } podClient = f.PodClient() logPodName = "log-pod-" + string(uuid.NewUUID()) err := createAndWaitPod(makeLogPod(logPodName, logString)) framework.ExpectNoError(err, "Failed waiting for pod: %s to enter success state", logPodName) }) It("should print log to correct log path", func() { logDir := kubelet.ContainerLogsDir // get containerID from created Pod createdLogPod, err := podClient.Get(logPodName, metav1.GetOptions{}) logContainerID := kubecontainer.ParseContainerID(createdLogPod.Status.ContainerStatuses[0].ContainerID) framework.ExpectNoError(err, "Failed to get pod: %s", logPodName) // build log file path expectedlogFile := logDir + "/" + logPodName + "_" + f.Namespace.Name + "_" + logContainerName + "-" + logContainerID.ID + ".log" logCheckPodName := "log-check-" + string(uuid.NewUUID()) err = createAndWaitPod(makeLogCheckPod(logCheckPodName, logString, expectedlogFile)) framework.ExpectNoError(err, "Failed waiting for pod: %s to enter success state", logCheckPodName) }) It("should print log to correct cri log path", func() { logCRIDir := "/var/log/pods" // get podID from created Pod createdLogPod, err := podClient.Get(logPodName, metav1.GetOptions{}) podID := string(createdLogPod.UID) // build log cri file path expectedCRILogFile := logCRIDir + "/" + podID + "/" + logContainerName + "/0.log" </ins> <del> podClient.Create(checkPod) err = framework.WaitForPodSuccessInNamespace(f.ClientSet, checkPodName, ns) framework.ExpectNoError(err, "Failed waiting for pod: %s to enter success state", checkPodName) </del> <ins> logCRICheckPodName := "log-cri-check-" + string(uuid.NewUUID()) err = createAndWaitPod(makeLogCheckPod(logCRICheckPodName, logString, expectedCRILogFile)) framework.ExpectNoError(err, "Failed waiting for pod: %s to enter success state", logCRICheckPodName) </ins> }) }) })