diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-08-27 22:52:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-27 22:52:58 +0200 |
commit | dba13352fe4f58b3cac12304efbda660c5989a16 (patch) | |
tree | 60e313c5cf2f9976ea7ad5386456c7f394b58f7b /libpod | |
parent | d46c7644cf631a67d86abb74b397096ec56bda6f (diff) | |
parent | 01a1bee360406780d59899c4ee86990d9a73aa92 (diff) | |
download | podman-dba13352fe4f58b3cac12304efbda660c5989a16.tar.gz podman-dba13352fe4f58b3cac12304efbda660c5989a16.tar.bz2 podman-dba13352fe4f58b3cac12304efbda660c5989a16.zip |
Merge pull request #3895 from mheon/backport_exit_codes
Backport fixes for v1.4.2 branch
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/events/journal_linux.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go index d5bce4334..e7e919d6d 100644 --- a/libpod/events/journal_linux.go +++ b/libpod/events/journal_linux.go @@ -4,6 +4,7 @@ package events import ( "fmt" + "strconv" "time" "github.com/coreos/go-systemd/journal" @@ -42,6 +43,9 @@ func (e EventJournalD) Write(ee Event) error { m["PODMAN_IMAGE"] = ee.Image m["PODMAN_NAME"] = ee.Name m["PODMAN_ID"] = ee.ID + if ee.ContainerExitCode != 0 { + m["PODMAN_EXIT_CODE"] = strconv.Itoa(ee.ContainerExitCode) + } case Volume: m["PODMAN_NAME"] = ee.Name } @@ -66,6 +70,11 @@ func (e EventJournalD) Read(options ReadOptions) error { if err := j.SeekTail(); err != nil { return errors.Wrap(err, "failed to seek end of journal") } + } else { + podmanJournal := sdjournal.Match{Field: "SYSLOG_IDENTIFIER", Value: "podman"} //nolint + if err := j.AddMatch(podmanJournal.String()); err != nil { + return errors.Wrap(err, "failed to add filter for event log") + } } // the api requires a next|prev before getting a cursor if _, err := j.Next(); err != nil { @@ -141,6 +150,14 @@ func newEventFromJournalEntry(entry *sdjournal.JournalEntry) (*Event, error) { / case Container, Pod: newEvent.ID = entry.Fields["PODMAN_ID"] newEvent.Image = entry.Fields["PODMAN_IMAGE"] + if code, ok := entry.Fields["PODMAN_EXIT_CODE"]; ok { + intCode, err := strconv.Atoi(code) + if err != nil { + logrus.Errorf("Error parsing event exit code %s", code) + } else { + newEvent.ContainerExitCode = intCode + } + } case Image: newEvent.ID = entry.Fields["PODMAN_ID"] } |