Skip to content

Commit

Permalink
Fix container exit code with Journald backend
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
mheon committed Aug 12, 2019
1 parent f634fd3 commit d3a4331
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libpod/events/journal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package events

import (
"fmt"
"strconv"
"time"

"github.com/coreos/go-systemd/journal"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -150,6 +152,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"]
}
Expand Down

0 comments on commit d3a4331

Please sign in to comment.