From 04d6ff058270006b98961e0f973ff6ee4c3ba8e8 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 25 Apr 2019 16:23:09 -0400 Subject: Add System event type and renumber, refresh events Also, re-add locking to file eventer Write() to protect against concurrent events. Signed-off-by: Matthew Heon --- libpod/events/events.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'libpod/events/events.go') diff --git a/libpod/events/events.go b/libpod/events/events.go index e8c61faa0..533eccbb8 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -49,6 +49,8 @@ func (e *Event) ToHumanReadable() string { humanFormat = fmt.Sprintf("%s %s %s %s (image=%s, name=%s)", e.Time, e.Type, e.Status, e.ID, e.Image, e.Name) case Image: humanFormat = fmt.Sprintf("%s %s %s %s %s", e.Time, e.Type, e.Status, e.ID, e.Name) + case System: + humanFormat = fmt.Sprintf("%s %s %s", e.Time, e.Type, e.Status) case Volume: humanFormat = fmt.Sprintf("%s %s %s %s", e.Time, e.Type, e.Status, e.Name) } @@ -85,6 +87,8 @@ func StringToType(name string) (Type, error) { return Image, nil case Pod.String(): return Pod, nil + case System.String(): + return System, nil case Volume.String(): return Volume, nil } @@ -135,8 +139,14 @@ func StringToStatus(name string) (Status, error) { return Pull, nil case Push.String(): return Push, nil + case Refresh.String(): + return Refresh, nil case Remove.String(): return Remove, nil + case Renumber.String(): + return Renumber, nil + case Restore.String(): + return Restore, nil case Save.String(): return Save, nil case Start.String(): -- cgit v1.2.3-54-g00ecf From e05af783295c9f4a0b210c0e6d368cf8c6dfe7c6 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Fri, 26 Apr 2019 10:50:57 -0400 Subject: Do not hard fail on non-decodable events Signed-off-by: Matthew Heon --- libpod/events/events.go | 5 ++--- libpod/events/journal_linux.go | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'libpod/events/events.go') diff --git a/libpod/events/events.go b/libpod/events/events.go index 533eccbb8..202c9db4e 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -92,7 +92,7 @@ func StringToType(name string) (Type, error) { case Volume.String(): return Volume, nil } - return "", errors.Errorf("unknown event type %s", name) + return "", errors.Errorf("unknown event type %q", name) } // StringToStatus converts a string to an Event Status @@ -111,7 +111,6 @@ func StringToStatus(name string) (Status, error) { case Commit.String(): return Commit, nil case Create.String(): - return Create, nil case Exec.String(): return Exec, nil @@ -164,7 +163,7 @@ func StringToStatus(name string) (Status, error) { case Untag.String(): return Untag, nil } - return "", errors.Errorf("unknown event status %s", name) + return "", errors.Errorf("unknown event status %q", name) } func (e EventLogFile) getTail(options ReadOptions) (*tail.Tail, error) { diff --git a/libpod/events/journal_linux.go b/libpod/events/journal_linux.go index e6b54db1d..8ba5bc2c7 100644 --- a/libpod/events/journal_linux.go +++ b/libpod/events/journal_linux.go @@ -7,6 +7,7 @@ import ( "github.com/coreos/go-systemd/journal" "github.com/coreos/go-systemd/sdjournal" "github.com/pkg/errors" + "github.com/sirupsen/logrus" ) // EventJournalD is the journald implementation of an eventer @@ -87,7 +88,11 @@ func (e EventJournalD) Read(options ReadOptions) error { } newEvent, err := newEventFromJournalEntry(entry) if err != nil { - return err + // We can't decode this event. + // Don't fail hard - that would make events unusable. + // Instead, log and continue. + logrus.Errorf("Unable to decode event: %v", err) + continue } include := true for _, filter := range eventOptions { -- cgit v1.2.3-54-g00ecf