Skip to content

Commit

Permalink
libct: suppress bogus "unable to terminate" warnings
Browse files Browse the repository at this point in the history
While working on a test case for [1], I got the following warning:

> level=warning msg="unable to terminate initProcess" error="exit status 1"

Obviously, the warning is bogus since the initProcess is terminated.

This is happening because terminate() can return errors from either
Kill() or Wait(), and the latter returns an error if the process has
not finished successfully (i.e. exit status is not 0 or it was killed).

Check for a particular error type and filter out those errors.

[1] opencontainers#2683

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Jan 6, 2021
1 parent 04b7b7d commit d7df301
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions libcontainer/container_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2067,9 +2067,17 @@ func ignoreTerminateErrors(err error) error {
if err == nil {
return nil
}
// terminate() might return an error from ether Kill or Wait.
// The (*Cmd).Wait documentation says: "If the command fails to run
// or doesn't complete successfully, the error is of type *ExitError".
// Filter out such errors (like "exit status 1" or "signal: killed").
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
return nil
}

s := err.Error()
if strings.Contains(s, "signal: killed") ||
strings.Contains(s, "process already finished") ||
if strings.Contains(s, "process already finished") ||
strings.Contains(s, "Wait was already called") {
return nil
}
Expand Down

0 comments on commit d7df301

Please sign in to comment.