Skip to content

Commit

Permalink
Fix Podman logs reading journald
Browse files Browse the repository at this point in the history
A podman could not read logs written to journald properly, due to a tail config bug.
Added a system test to check this - since e2e tests don't like journald

Signed-off-by: Ashley Cui <[email protected]>
  • Loading branch information
ashley-cui committed Oct 2, 2020
1 parent b0e70a6 commit c0d1954
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libpod/container_log_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const (
func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOptions, logChannel chan *logs.LogLine) error {
var config journal.JournalReaderConfig
if options.Tail < 0 {
config.NumFromTail = math.MaxUint64
config.NumFromTail = 0
} else {
config.NumFromTail = uint64(options.Tail)
}
Expand Down
1 change: 1 addition & 0 deletions test/e2e/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ var _ = Describe("Podman logs", func() {
results.WaitWithDefaultTimeout()
Expect(results).To(Exit(0))
Expect(len(results.OutputToStringArray())).To(Equal(3))
Expect(results.OutputToString()).To(Equal("podman podman podman"))
})

It("using journald tail two lines", func() {
Expand Down
11 changes: 11 additions & 0 deletions test/system/035-logs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,15 @@ ${cid[1]} c
${cid[0]} d" "Sequential output from logs"
}

@test "podman logs over journald" {
msg=$(random_string 20)

run_podman run --name myctr --log-driver journald $IMAGE echo $msg

run_podman logs myctr
is "$output" "$msg" "check that log output equals the container output"

run_podman rm myctr
}

# vim: filetype=sh

0 comments on commit c0d1954

Please sign in to comment.