From c0d1954663fbf56076d1e75da396aa78016d623b Mon Sep 17 00:00:00 2001 From: Ashley Cui Date: Fri, 2 Oct 2020 08:54:16 -0400 Subject: [PATCH] Fix Podman logs reading journald 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 --- libpod/container_log_linux.go | 2 +- test/e2e/logs_test.go | 1 + test/system/035-logs.bats | 11 +++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index 73c2df76eb..d895171cf5 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -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) } diff --git a/test/e2e/logs_test.go b/test/e2e/logs_test.go index 3aa3cf409c..67ab71d201 100644 --- a/test/e2e/logs_test.go +++ b/test/e2e/logs_test.go @@ -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() { diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index cbb2091e57..130bc52436 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -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