summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2020-05-21 10:48:39 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2020-05-21 10:49:13 -0400
commitf20694cc96eb335eab125dc7228a0a6dd6fe26cb (patch)
tree272bc19734d160c728a1142b1469346beba063b2
parenta852afab2f37026fa8a45d115c61cd77fb3e7ef1 (diff)
downloadpodman-f20694cc96eb335eab125dc7228a0a6dd6fe26cb.tar.gz
podman-f20694cc96eb335eab125dc7228a0a6dd6fe26cb.tar.bz2
podman-f20694cc96eb335eab125dc7228a0a6dd6fe26cb.zip
Get proper exit code when running or starting a container.
When we finish running a container, we need to call wait in order to get the exit code from the container. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r--pkg/domain/infra/tunnel/containers.go20
-rw-r--r--test/e2e/run_exit_test.go1
2 files changed, 18 insertions, 3 deletions
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 445b49ba8..d02c54e76 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -360,10 +360,19 @@ func (ic *ContainerEngine) ContainerStart(ctx context.Context, namesOrIds []stri
report := entities.ContainerStartReport{Id: name}
if options.Attach {
report.Err = startAndAttach(ic, name, &options.DetachKeys, options.Stdin, options.Stdout, options.Stderr)
+ if report.Err == nil {
+ exitCode, err := containers.Wait(ic.ClientCxt, name, nil)
+ if err == nil {
+ report.ExitCode = int(exitCode)
+ }
+ } else {
+ report.ExitCode = define.ExitCode(report.Err)
+ }
reports = append(reports, &report)
return reports, nil
}
report.Err = containers.Start(ic.ClientCxt, name, &options.DetachKeys)
+ report.ExitCode = define.ExitCode(report.Err)
reports = append(reports, &report)
}
return reports, nil
@@ -385,11 +394,18 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
// Attach
if !opts.Detach {
err = startAndAttach(ic, con.ID, &opts.DetachKeys, opts.InputStream, opts.OutputStream, opts.ErrorStream)
-
+ if err == nil {
+ exitCode, err := containers.Wait(ic.ClientCxt, con.ID, nil)
+ if err == nil {
+ report.ExitCode = int(exitCode)
+ }
+ }
} else {
err = containers.Start(ic.ClientCxt, con.ID, nil)
}
- report.ExitCode = define.ExitCode(err)
+ if err != nil {
+ report.ExitCode = define.ExitCode(err)
+ }
return &report, err
}
diff --git a/test/e2e/run_exit_test.go b/test/e2e/run_exit_test.go
index d4b44ff23..40731142e 100644
--- a/test/e2e/run_exit_test.go
+++ b/test/e2e/run_exit_test.go
@@ -62,7 +62,6 @@ var _ = Describe("Podman run exit", func() {
})
It("podman run exit 50", func() {
- Skip(v2remotefail)
result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"})
result.WaitWithDefaultTimeout()
Expect(result.ExitCode()).To(Equal(50))