summaryrefslogtreecommitdiff
path: root/pkg/domain/infra/tunnel
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-21 17:46:59 +0200
committerGitHub <noreply@github.com>2020-05-21 17:46:59 +0200
commit6409ff6781c4ec51dc7e108b5f907dcb37b34635 (patch)
tree41cf88a64844fe6112b21441f73ba11182e62c3c /pkg/domain/infra/tunnel
parent363f8820bc6d9ee19d2c95cfcbb05e93938cd53c (diff)
parentf20694cc96eb335eab125dc7228a0a6dd6fe26cb (diff)
downloadpodman-6409ff6781c4ec51dc7e108b5f907dcb37b34635.tar.gz
podman-6409ff6781c4ec51dc7e108b5f907dcb37b34635.tar.bz2
podman-6409ff6781c4ec51dc7e108b5f907dcb37b34635.zip
Merge pull request #6319 from rhatdan/exit
Get proper exit code when running or starting a container.
Diffstat (limited to 'pkg/domain/infra/tunnel')
-rw-r--r--pkg/domain/infra/tunnel/containers.go20
1 files changed, 18 insertions, 2 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
}