diff options
author | Matthew Heon <matthew.heon@pm.me> | 2019-07-10 15:41:35 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2019-07-31 17:28:42 -0400 |
commit | 7dd1df43231ba53e7d334c5272f93336a1ac32a5 (patch) | |
tree | e31763073e9b3d6fdda2ac7d51fa907c0c97c2d9 /pkg/adapter | |
parent | ebacfbd091f709d7ca0b811a9fe1fee57c6f0ad3 (diff) | |
download | podman-7dd1df43231ba53e7d334c5272f93336a1ac32a5.tar.gz podman-7dd1df43231ba53e7d334c5272f93336a1ac32a5.tar.bz2 podman-7dd1df43231ba53e7d334c5272f93336a1ac32a5.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>
Diffstat (limited to 'pkg/adapter')
-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 525b1f29b..155454e21 100644 --- a/pkg/adapter/containers.go +++ b/pkg/adapter/containers.go @@ -22,6 +22,7 @@ import ( "github.com/containers/libpod/cmd/podman/shared/parse" "github.com/containers/libpod/libpod" "github.com/containers/libpod/libpod/define" + "github.com/containers/libpod/libpod/events" "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/libpod/logs" "github.com/containers/libpod/pkg/adapter/shortcuts" @@ -417,8 +418,14 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == define.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) @@ -622,8 +629,14 @@ func (r *LocalRuntime) Start(ctx context.Context, c *cliconfig.StartValues, sigP if ecode, err := ctr.Wait(); err != nil { if errors.Cause(err) == define.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) |