Skip to content

Commit

Permalink
Merge pull request containers#12130 from rhatdan/journal
Browse files Browse the repository at this point in the history
Error logs --follow if events-backend != journald, event-logger=journald
  • Loading branch information
openshift-merge-robot authored Nov 15, 2021
2 parents 47eaf23 + 062c887 commit 230f0b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libpod/container_log_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
11 changes: 11 additions & 0 deletions test/system/090-events.bats
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,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 ""
}

0 comments on commit 230f0b6

Please sign in to comment.