From 4b347609d683835370e6500b25fda9c70442424d Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Sat, 26 Aug 2023 22:37:45 +0200 Subject: [PATCH] oci: print stderr only after checking state when the "kill" command fails, print the stderr from the OCI runtime only after we check the container state. It also simplifies the code since we don't have to hard code the error messages we want to ignore. Closes: https://github.com/containers/podman/issues/18452 [NO NEW TESTS NEEDED] it fixes a flake. Signed-off-by: Giuseppe Scrivano --- libpod/oci_conmon_common.go | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/libpod/oci_conmon_common.go b/libpod/oci_conmon_common.go index f315d94397..abfe34a36f 100644 --- a/libpod/oci_conmon_common.go +++ b/libpod/oci_conmon_common.go @@ -420,22 +420,6 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool) killCtr := func(signal uint) (bool, error) { stderr, err := r.killContainer(ctr, signal, all, true) - - // Before handling error from KillContainer, convert STDERR to a []string - // (one string per line of output) and print it, ignoring known OCI runtime - // errors that we don't care about - stderrLines := strings.Split(stderr.String(), "\n") - for _, line := range stderrLines { - if line == "" { - continue - } - if strings.Contains(line, "container not running") || strings.Contains(line, "open pidfd: No such process") || strings.Contains(line, "kill container: No such process") { - logrus.Debugf("Failure to kill container (already stopped?): logged %s", line) - continue - } - fmt.Fprintf(os.Stderr, "%s\n", line) - } - if err != nil { // There's an inherent race with the cleanup process (see // #16142, #17142). If the container has already been marked as @@ -461,6 +445,16 @@ func (r *ConmonOCIRuntime) StopContainer(ctr *Container, timeout uint, all bool) return false, err } + + // Before handling error from KillContainer, convert STDERR to a []string + // (one string per line of output) and print it. + stderrLines := strings.Split(stderr.String(), "\n") + for _, line := range stderrLines { + if line != "" { + fmt.Fprintf(os.Stderr, "%s\n", line) + } + } + return false, nil }