diff options
author | Matthew Heon <mheon@redhat.com> | 2020-10-29 16:34:03 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2020-10-30 09:23:47 -0400 |
commit | ed9edf840adbc159fb3ddc99638b3111440c8cfe (patch) | |
tree | f329dee3fd536dae5b80c9bac19df5af83bc2eb6 /pkg/domain/infra/abi/terminal/sigproxy_linux.go | |
parent | 4d87306fbe06674b16f188fea187282f29c0dc58 (diff) | |
download | podman-ed9edf840adbc159fb3ddc99638b3111440c8cfe.tar.gz podman-ed9edf840adbc159fb3ddc99638b3111440c8cfe.tar.bz2 podman-ed9edf840adbc159fb3ddc99638b3111440c8cfe.zip |
When container stops, drop sig-proxy errors to infos
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 <mheon@redhat.com>
Diffstat (limited to 'pkg/domain/infra/abi/terminal/sigproxy_linux.go')
-rw-r--r-- | pkg/domain/infra/abi/terminal/sigproxy_linux.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/terminal/sigproxy_linux.go b/pkg/domain/infra/abi/terminal/sigproxy_linux.go index 0c586cf5c..2aca8f22d 100644 --- a/pkg/domain/infra/abi/terminal/sigproxy_linux.go +++ b/pkg/domain/infra/abi/terminal/sigproxy_linux.go @@ -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" ) @@ -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()) |