Skip to content

Commit

Permalink
When container stops, drop sig-proxy errors to infos
Browse files Browse the repository at this point in the history
The sig-proxy code is set up to error on failing to forward
signals to a container. This is reasonable in cases where the
container is running, but something strange went wrong - but when
the Kill fails because the container is stopped, we shouldn't
bother with aggressive Error logging since this is an expected
part of the container lifecycle - it stops, and then `podman run`
also stops, but there is a timing window in between where signals
will fail to be proxied, and we should not print angry errors
during that.

Signed-off-by: Matthew Heon <[email protected]>
  • Loading branch information
mheon committed Oct 30, 2020
1 parent 4d87306 commit ed9edf8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/domain/infra/abi/terminal/sigproxy_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"syscall"

"github.com/containers/podman/v2/libpod"
"github.com/containers/podman/v2/libpod/define"
"github.com/containers/podman/v2/libpod/shutdown"
"github.com/containers/podman/v2/pkg/signal"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)

Expand All @@ -33,12 +35,16 @@ func ProxySignals(ctr *libpod.Container) {
}

if err := ctr.Kill(uint(s.(syscall.Signal))); err != nil {
if errors.Cause(err) == define.ErrCtrStateInvalid {
logrus.Infof("Ceasing signal forwarding to container %s as it has stopped", ctr.ID())
} else {
logrus.Errorf("Error forwarding signal %d to container %s: %v", s, ctr.ID(), err)
}
// If the container dies, and we find out here,
// we need to forward that one signal to
// ourselves so that it is not lost, and then
// we terminate the proxy and let the defaults
// play out.
logrus.Errorf("Error forwarding signal %d to container %s: %v", s, ctr.ID(), err)
signal.StopCatch(sigBuffer)
if err := syscall.Kill(syscall.Getpid(), s.(syscall.Signal)); err != nil {
logrus.Errorf("failed to kill pid %d", syscall.Getpid())
Expand Down

0 comments on commit ed9edf8

Please sign in to comment.