diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-10-28 08:54:47 -0400 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-12-06 14:31:01 -0500 |
commit | 76ada2c0119430d10f5aad423120b4b082d3570d (patch) | |
tree | 9586ccf0f11f14b953db9aff48801b932a862628 | |
parent | 579d91c2f9f1fc9d0e3191db1e1d86e106ec4653 (diff) | |
download | podman-76ada2c0119430d10f5aad423120b4b082d3570d.tar.gz podman-76ada2c0119430d10f5aad423120b4b082d3570d.tar.bz2 podman-76ada2c0119430d10f5aad423120b4b082d3570d.zip |
Error logs --follow if events-backend != journald, event-logger=journald
Fixes: https://github.com/containers/podman/issues/11255
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
-rw-r--r-- | libpod/container_log_linux.go | 12 | ||||
-rw-r--r-- | test/system/090-events.bats | 11 |
2 files changed, 17 insertions, 6 deletions
diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index b6b780bab..73a081c75 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -44,6 +44,12 @@ func (c *Container) initializeJournal(ctx context.Context) error { } func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOptions, logChannel chan *logs.LogLine) error { + // We need the container's events in the same journal to guarantee + // consistency, see #10323. + if options.Follow && c.runtime.config.Engine.EventsLogger != "journald" { + return errors.Errorf("using --follow with the journald --log-driver but without the journald --events-backend (%s) is not supported", c.runtime.config.Engine.EventsLogger) + } + journal, err := sdjournal.NewJournal() if err != nil { return err @@ -105,12 +111,6 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption return errors.Wrap(cursorError, "initial journal cursor") } - // We need the container's events in the same journal to guarantee - // consistency, see #10323. - if options.Follow && c.runtime.config.Engine.EventsLogger != "journald" { - return errors.Errorf("using --follow with the journald --log-driver but without the journald --events-backend (%s) is not supported", c.runtime.config.Engine.EventsLogger) - } - options.WaitGroup.Add(1) go func() { defer func() { diff --git a/test/system/090-events.bats b/test/system/090-events.bats index 22edaeee9..f8a7a87c8 100644 --- a/test/system/090-events.bats +++ b/test/system/090-events.bats @@ -85,6 +85,17 @@ function _events_disjunctive_filters() { _events_disjunctive_filters --events-backend=journald } +@test "events with file backend and journald logdriver with --follow failure" { + skip_if_remote "remote does not support --events-backend" + skip_if_journald_unavailable "system does not support journald events" + run_podman --events-backend=file run --log-driver=journald --name=test $IMAGE echo hi + is "$output" "hi" "Should support events-backend=file" + + run_podman 125 --events-backend=file logs --follow test + is "$output" "Error: using --follow with the journald --log-driver but without the journald --events-backend (file) is not supported" "Should fail with reasonable error message when events-backend and events-logger do not match" + +} + @test "events with disjunctive filters - default" { _events_disjunctive_filters "" } |