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 <acui@redhat.com>
This commit is contained in:
Ashley Cui
2020-10-02 08:54:16 -04:00
parent b0e70a6411
commit c0d1954663
3 changed files with 13 additions and 1 deletions

View File

@ -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)
}

View File

@ -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() {

View File

@ -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