diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-08-02 03:44:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-02 03:44:43 +0200 |
commit | e3240daa471dee1bbc118e6b3871c4a73890d0e0 (patch) | |
tree | 402bfadad932067a96635f799d3c3fd98282d5b2 /libpod/events | |
parent | e48dc506d18335b36d1ffbbc8df1890ee3b99e2c (diff) | |
parent | 8da24f2f7d3472d2be4ccde8e7b42790671d464f (diff) | |
download | podman-e3240daa471dee1bbc118e6b3871c4a73890d0e0.tar.gz podman-e3240daa471dee1bbc118e6b3871c4a73890d0e0.tar.bz2 podman-e3240daa471dee1bbc118e6b3871c4a73890d0e0.zip |
Merge pull request #3551 from mheon/fix_memory_leak
Fix memory leak with exit files
Diffstat (limited to 'libpod/events')
-rw-r--r-- | libpod/events/config.go | 2 | ||||
-rw-r--r-- | libpod/events/events.go | 23 | ||||
-rw-r--r-- | libpod/events/events_linux.go | 4 | ||||
-rw-r--r-- | libpod/events/logfile.go | 2 |
4 files changed, 27 insertions, 4 deletions
diff --git a/libpod/events/config.go b/libpod/events/config.go index b9f01f3a5..96172d47b 100644 --- a/libpod/events/config.go +++ b/libpod/events/config.go @@ -14,6 +14,8 @@ const ( LogFile EventerType = iota // Journald indicates journald should be used to log events Journald EventerType = iota + // Null is a no-op events logger. It does not read or write events. + Null EventerType = iota ) // Event describes the attributes of a libpod event diff --git a/libpod/events/events.go b/libpod/events/events.go index 2bebff162..5e828bc8a 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -16,11 +16,30 @@ var ErrNoJournaldLogging = errors.New("No support for journald logging") // String returns a string representation of EventerType func (et EventerType) String() string { - if et == LogFile { + switch et { + case LogFile: return "file" + case Journald: + return "journald" + case Null: + return "none" + default: + return "invalid" + } +} +// IsValidEventer checks if the given string is a valid eventer type. +func IsValidEventer(eventer string) bool { + switch eventer { + case LogFile.String(): + return true + case Journald.String(): + return true + case Null.String(): + return true + default: + return false } - return "journald" } // NewEvent creates a event struct and populates with diff --git a/libpod/events/events_linux.go b/libpod/events/events_linux.go index 11f309574..ffb100be8 100644 --- a/libpod/events/events_linux.go +++ b/libpod/events/events_linux.go @@ -18,8 +18,10 @@ func NewEventer(options EventerOptions) (eventer Eventer, err error) { } case strings.ToUpper(LogFile.String()): eventer = EventLogFile{options} + case strings.ToUpper(Null.String()): + eventer = NewNullEventer() default: - return eventer, errors.Errorf("unknown event logger type: %s", strings.ToUpper(options.EventerType)) + return nil, errors.Errorf("unknown event logger type: %s", strings.ToUpper(options.EventerType)) } return eventer, nil } diff --git a/libpod/events/logfile.go b/libpod/events/logfile.go index e5efc09bb..30d72b9fc 100644 --- a/libpod/events/logfile.go +++ b/libpod/events/logfile.go @@ -55,7 +55,7 @@ func (e EventLogFile) Read(options ReadOptions) error { return err } switch event.Type { - case Image, Volume, Pod, Container: + case Image, Volume, Pod, System, Container: // no-op default: return errors.Errorf("event type %s is not valid in %s", event.Type.String(), e.options.LogFilePath) |