From 8e8d1ac1933e3891c597ea1b12e434d365b7d164 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Tue, 16 Jul 2019 15:56:24 -0400 Subject: Add a flag to set events logger type Signed-off-by: Matthew Heon --- libpod/events/events.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'libpod/events') diff --git a/libpod/events/events.go b/libpod/events/events.go index 2bebff162..a898171c1 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -23,6 +23,18 @@ func (et EventerType) String() string { return "journald" } +// 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 + default: + return false + } +} + // NewEvent creates a event struct and populates with // the given status and time. func NewEvent(status Status) Event { -- cgit v1.2.3-54-g00ecf From cdd5639d564624a6fbca426421d47c840dac8556 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 17 Jul 2019 15:17:26 -0400 Subject: Expose Null eventer and allow its use in the Podman CLI We need this specifically for tests, but others may find it useful if they don't explicitly need events and don't want the performance implications of using them. Signed-off-by: Matthew Heon --- docs/libpod.conf.5.md | 2 +- docs/podman.1.md | 2 +- libpod/events/config.go | 2 ++ libpod/events/events.go | 13 ++++++++++--- libpod/events/events_linux.go | 4 +++- 5 files changed, 17 insertions(+), 6 deletions(-) (limited to 'libpod/events') diff --git a/docs/libpod.conf.5.md b/docs/libpod.conf.5.md index 097d0764a..0bdba4593 100644 --- a/docs/libpod.conf.5.md +++ b/docs/libpod.conf.5.md @@ -99,7 +99,7 @@ libpod to manage containers. a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable. **events_logger**="" - Default method to use when logging events. Valid values are "journald" and "file". + Default method to use when logging events. Valid values are "file", "journald", and "null". **detach_keys**="" Keys sequence used for detaching a container diff --git a/docs/podman.1.md b/docs/podman.1.md index 02d15c197..7aa15019a 100644 --- a/docs/podman.1.md +++ b/docs/podman.1.md @@ -38,7 +38,7 @@ Path to where the cpu performance results should be written **--events-logger**=**type** -Backend to use for storing events. Allowed values are **journald** and **file**. +Backend to use for storing events. Allowed values are **file**, **journald**, and **null**. **--hooks-dir**=*path* 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 a898171c1..a80e97e90 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -16,11 +16,16 @@ 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 "null" + default: + return "invalid" } - return "journald" } // IsValidEventer checks if the given string is a valid eventer type. @@ -30,6 +35,8 @@ func IsValidEventer(eventer string) bool { return true case Journald.String(): return true + case Null.String(): + return true default: return false } 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 } -- cgit v1.2.3-54-g00ecf From cc63aff571fd5ebf13a493fab923a829176c5108 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 18 Jul 2019 15:22:18 -0400 Subject: System events are valid, don't error on them The logfile driver was not aware that system events existed. Signed-off-by: Matthew Heon --- libpod/events/logfile.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libpod/events') 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) -- cgit v1.2.3-54-g00ecf From 8da24f2f7d3472d2be4ccde8e7b42790671d464f Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 1 Aug 2019 14:57:29 -0400 Subject: Use "none" instead of "null" for the null eventer Signed-off-by: Matthew Heon --- docs/libpod.conf.5.md | 2 +- docs/podman.1.md | 4 ++-- libpod/events/events.go | 2 +- test/e2e/libpod_suite_test.go | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'libpod/events') diff --git a/docs/libpod.conf.5.md b/docs/libpod.conf.5.md index 0bdba4593..4240ae15a 100644 --- a/docs/libpod.conf.5.md +++ b/docs/libpod.conf.5.md @@ -99,7 +99,7 @@ libpod to manage containers. a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable. **events_logger**="" - Default method to use when logging events. Valid values are "file", "journald", and "null". + Default method to use when logging events. Valid values are "file", "journald", and "none". **detach_keys**="" Keys sequence used for detaching a container diff --git a/docs/podman.1.md b/docs/podman.1.md index 7aa15019a..bfb5a9aec 100644 --- a/docs/podman.1.md +++ b/docs/podman.1.md @@ -36,9 +36,9 @@ Note: CGroup manager is not supported in rootless mode when using CGroups Versio Path to where the cpu performance results should be written -**--events-logger**=**type** +**--events-logger**=*type* -Backend to use for storing events. Allowed values are **file**, **journald**, and **null**. +Backend to use for storing events. Allowed values are **file**, **journald**, and **none**. **--hooks-dir**=*path* diff --git a/libpod/events/events.go b/libpod/events/events.go index a80e97e90..5e828bc8a 100644 --- a/libpod/events/events.go +++ b/libpod/events/events.go @@ -22,7 +22,7 @@ func (et EventerType) String() string { case Journald: return "journald" case Null: - return "null" + return "none" default: return "invalid" } diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index 841c8a9ca..1df59dbe3 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -74,7 +74,7 @@ func (p *PodmanTestIntegration) makeOptions(args []string, noEvents bool) []stri eventsType := "file" if noEvents { - eventsType = "null" + eventsType = "none" } podmanOptions := strings.Split(fmt.Sprintf("%s--root %s --runroot %s --runtime %s --conmon %s --cni-config-dir %s --cgroup-manager %s --tmpdir %s --events-backend %s", -- cgit v1.2.3-54-g00ecf