diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index ef707238f4..28108dab48 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -1009,7 +1009,7 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co defer errorhandling.CloseQuiet(parentStartPipe) var ociLog string - if logrus.GetLevel() != logrus.DebugLevel && r.supportsJSON { + if r.supportsJSON { ociLog = filepath.Join(ctr.state.RunDir, "oci-log") } diff --git a/libpod/oci_conmon_exec_common.go b/libpod/oci_conmon_exec_common.go index c002e04f2f..8ff2019378 100644 --- a/libpod/oci_conmon_exec_common.go +++ b/libpod/oci_conmon_exec_common.go @@ -47,10 +47,7 @@ func (r *ConmonOCIRuntime) ExecContainer(c *Container, sessionID string, options attachStdin = streams.AttachInput } - var ociLog string - if logrus.GetLevel() != logrus.DebugLevel && r.supportsJSON { - ociLog = c.execOCILog(sessionID) - } + ociLog := c.execOCILog(sessionID) execCmd, pipes, err := r.startExec(c, sessionID, options, attachStdin, ociLog) if err != nil { @@ -115,10 +112,7 @@ func (r *ConmonOCIRuntime) ExecContainerHTTP(ctr *Container, sessionID string, o attachStdin = streams.Stdin } - var ociLog string - if logrus.GetLevel() != logrus.DebugLevel && r.supportsJSON { - ociLog = ctr.execOCILog(sessionID) - } + ociLog := ctr.execOCILog(sessionID) execCmd, pipes, err := r.startExec(ctr, sessionID, options, attachStdin, ociLog) if err != nil { @@ -163,10 +157,7 @@ func (r *ConmonOCIRuntime) ExecContainerDetached(ctr *Container, sessionID strin return -1, fmt.Errorf("must provide exec options to ExecContainerHTTP: %w", define.ErrInvalidArg) } - var ociLog string - if logrus.GetLevel() != logrus.DebugLevel && r.supportsJSON { - ociLog = ctr.execOCILog(sessionID) - } + ociLog := ctr.execOCILog(sessionID) execCmd, pipes, err := r.startExec(ctr, sessionID, options, stdin, ociLog) if err != nil { diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 4009445d1e..817f1c7f5b 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -671,4 +671,19 @@ RUN useradd -u 1000 auser`, FEDORA_MINIMAL) execSession.WaitWithDefaultTimeout() Expect(execSession).Should(ExitWithError(137, "")) }) + + It("podman exec command not in $PATH error", func() { + session := podmanTest.RunTopContainer("testctr") + session.WaitWithDefaultTimeout() + Expect(session).Should(ExitCleanly()) + + execResult := podmanTest.Podman([]string{"exec", "testctr", "kjhasdf"}) + execResult.WaitWithDefaultTimeout() + Expect(execResult).Should(ExitWithError(127, "not found in $PATH")) + + // Test again with log level debug, this must produce the same error + execResult = podmanTest.Podman([]string{"--log-level=debug", "exec", "testctr", "kjhasdf"}) + execResult.WaitWithDefaultTimeout() + Expect(execResult).Should(ExitWithError(127, "not found in $PATH")) + }) })