k8s-file: podman logs --until --follow exit after time

When you use podman logs with --until and --follow it should exit after
the requested until time and not keep hanging forever.

This fixes the behavior for the k8s-file backend.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2023-01-04 18:59:53 +01:00
parent 767947ab88
commit 6038200fe0
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
2 changed files with 12 additions and 0 deletions

View File

@ -72,6 +72,14 @@ func (c *Container) readFromLogFile(ctx context.Context, options *logs.LogOption
}
}
}
go func() {
if options.Until.After(time.Now()) {
time.Sleep(time.Until(options.Until))
if err := t.Stop(); err != nil {
logrus.Errorf("Stopping logger: %v", err)
}
}
}()
go func() {
defer options.WaitGroup.Done()

View File

@ -373,6 +373,10 @@ $content" "logs --until -f on running container works"
run_podman ${events_backend} rm -t 0 -f $cname
}
@test "podman logs - --until --follow k8s-file" {
_log_test_follow_until k8s-file
}
@test "podman logs - --until --follow journald" {
# We can't use journald on RHEL as rootless: rhbz#1895105
skip_if_journald_unavailable