summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-08-12 16:30:05 -0400
committerMatthew Heon <mheon@redhat.com>2019-08-27 15:45:43 -0400
commit3849d8cbfb4031d2625b015fa421d4f44f23a6b4 (patch)
tree69edc40f433e1705b1441c0fd0296a3e28422665 /libpod
parentd46c7644cf631a67d86abb74b397096ec56bda6f (diff)
downloadpodman-3849d8cbfb4031d2625b015fa421d4f44f23a6b4.tar.gz
podman-3849d8cbfb4031d2625b015fa421d4f44f23a6b4.tar.bz2
podman-3849d8cbfb4031d2625b015fa421d4f44f23a6b4.zip
Fix container exit code with Journald backend
We weren't actually storing this, so we'd lose the exit code for containers run with --rm or force-removed while running if the journald backend for events was in use. Fixes #3795 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/events/journal_linux.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go
index d5bce4334..94fceccb1 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,7 @@ func (e EventJournalD) Write(ee Event) error {
m["PODMAN_IMAGE"] = ee.Image
m["PODMAN_NAME"] = ee.Name
m["PODMAN_ID"] = ee.ID
+ m["PODMAN_EXIT_CODE"] = strconv.Itoa(ee.ContainerExitCode)
case Volume:
m["PODMAN_NAME"] = ee.Name
}
@@ -141,6 +143,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"]
}