aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-08-05 21:59:24 +0200
committerGitHub <noreply@github.com>2019-08-05 21:59:24 +0200
commitd46c7644cf631a67d86abb74b397096ec56bda6f (patch)
treed5ffcbc28ec1769cab3ecf53fe9abfdc55c65841 /pkg
parent3b1ee6990c0e90e0a7ee4233e3ce3bc6487c8a4f (diff)
parent29c137ff665314f18a65cf55ba55522e702987b3 (diff)
downloadpodman-d46c7644cf631a67d86abb74b397096ec56bda6f.tar.gz
podman-d46c7644cf631a67d86abb74b397096ec56bda6f.tar.bz2
podman-d46c7644cf631a67d86abb74b397096ec56bda6f.zip
Merge pull request #3724 from mheon/v1.4.2-stable1
V1.4.2 stable1
Diffstat (limited to 'pkg')
-rw-r--r--pkg/adapter/containers.go50
-rw-r--r--pkg/spec/createconfig.go3
2 files changed, 10 insertions, 43 deletions
diff --git a/pkg/adapter/containers.go b/pkg/adapter/containers.go
index 40b1e6b43..4cc776c1b 100644
--- a/pkg/adapter/containers.go
+++ b/pkg/adapter/containers.go
@@ -7,9 +7,7 @@ import (
"context"
"fmt"
"io"
- "io/ioutil"
"os"
- "path/filepath"
"strconv"
"strings"
"sync"
@@ -21,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"
@@ -404,18 +403,13 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode
if ecode, err := ctr.Wait(); err != nil {
if errors.Cause(err) == libpod.ErrNoSuchCtr {
- // The container may have been removed
- // Go looking for an exit file
- config, err := r.Runtime.GetConfig()
- if err != nil {
- return exitCode, err
- }
- ctrExitCode, err := ReadExitFile(config.TmpDir, ctr.ID())
+ // 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 = ctrExitCode
+ exitCode = event.ContainerExitCode
}
}
} else {
@@ -431,31 +425,6 @@ func (r *LocalRuntime) Run(ctx context.Context, c *cliconfig.RunValues, exitCode
return exitCode, nil
}
-// ReadExitFile reads a container's exit file
-func ReadExitFile(runtimeTmp, ctrID string) (int, error) {
- exitFile := filepath.Join(runtimeTmp, "exits", fmt.Sprintf("%s-old", ctrID))
-
- logrus.Debugf("Attempting to read container %s exit code from file %s", ctrID, exitFile)
-
- // Check if it exists
- if _, err := os.Stat(exitFile); err != nil {
- return 0, errors.Wrapf(err, "error getting exit file for container %s", ctrID)
- }
-
- // File exists, read it in and convert to int
- statusStr, err := ioutil.ReadFile(exitFile)
- if err != nil {
- return 0, errors.Wrapf(err, "error reading exit file for container %s", ctrID)
- }
-
- exitCode, err := strconv.Atoi(string(statusStr))
- if err != nil {
- return 0, errors.Wrapf(err, "error parsing exit code for container %s", ctrID)
- }
-
- return exitCode, nil
-}
-
// Ps ...
func (r *LocalRuntime) Ps(c *cliconfig.PsValues, opts shared.PsOptions) ([]shared.PsContainerOutput, error) {
maxWorkers := shared.Parallelize("ps")
@@ -627,18 +596,13 @@ func (r *LocalRuntime) Start(ctx context.Context, c *cliconfig.StartValues, sigP
if ecode, err := ctr.Wait(); err != nil {
if errors.Cause(err) == libpod.ErrNoSuchCtr {
- // The container may have been removed
- // Go looking for an exit file
- rtc, err := r.GetConfig()
- if err != nil {
- return 0, err
- }
- ctrExitCode, err := ReadExitFile(rtc.TmpDir, ctr.ID())
+ // 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 = ctrExitCode
+ exitCode = event.ContainerExitCode
}
}
} else {
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go
index a8413d6c7..eaebf119d 100644
--- a/pkg/spec/createconfig.go
+++ b/pkg/spec/createconfig.go
@@ -165,6 +165,9 @@ func (c *CreateConfig) createExitCommand(runtime *libpod.Runtime) ([]string, err
for _, opt := range config.StorageConfig.GraphDriverOptions {
command = append(command, []string{"--storage-opt", opt}...)
}
+ if config.EventsLogger != "" {
+ command = append(command, []string{"--events-backend", config.EventsLogger}...)
+ }
if c.Syslog {
command = append(command, "--syslog", "true")