diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-07-10 15:41:35 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-08-05 14:40:28 -0400 |
commit | 37e33dd1c2aa43ccc7a828518e9acc47a1273a30 (patch) | |
tree | 2f3e42766290951d5958e469309a5f38b90dd2ea /pkg | |
parent | c115f4eca0973a42e33dd87a82f5b9166e5b6331 (diff) | |
download | podman-37e33dd1c2aa43ccc7a828518e9acc47a1273a30.tar.gz podman-37e33dd1c2aa43ccc7a828518e9acc47a1273a30.tar.bz2 podman-37e33dd1c2aa43ccc7a828518e9acc47a1273a30.zip |
Retrieve exit codes for containers via events
As we previously removed our exit code retrieval code to stop a
memory leak, we need a new way of doing this. Fortunately, events
is able to do the job for us.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
<Cherry-pick into 1.4.2>
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/adapter/containers.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go index 50953909c..4cc776c1b 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -19,6 +19,7 @@ import ( "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/shared" "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/events" "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/pkg/adapter/shortcuts" "github.com/containers/libpod/pkg/systemdgen" @@ -402,8 +403,14 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == libpod.ErrNoSuchCtr { - logrus.Errorf("Cannot get exit code: %v", err) - exitCode = 127 + // Check events + event, err := r.Runtime.GetLastContainerEvent(ctr.ID(), events.Exited) + if err != nil { + logrus.Errorf("Cannot get exit code: %v", err) + exitCode = 127 + } else { + exitCode = event.ContainerExitCode + } } } else { exitCode = int(ecode) @@ -589,8 +596,14 @@ func (r *LocalRuntime) Start(ctx context.Context, c *cliconfig.StartValues, sigP if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == libpod.ErrNoSuchCtr { - logrus.Errorf("Cannot get exit code: %v", err) - exitCode = 127 + // Check events + event, err := r.Runtime.GetLastContainerEvent(ctr.ID(), events.Exited) + if err != nil { + logrus.Errorf("Cannot get exit code: %v", err) + exitCode = 127 + } else { + exitCode = event.ContainerExitCode + } } } else { exitCode = int(ecode) |