diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-14 07:22:52 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-14 07:22:52 -0400 |
commit | 5771f822607214f7b9b61204c82d9f7eb228b6bb (patch) | |
tree | 25ef8a41deb6444cced3c4fb6eabb1e392cce43f | |
parent | 001f619eab780721abe52ee72fe3c87caa7c652f (diff) | |
parent | 63c38b99f40224c46ecf609feba05cd3bc5c4da2 (diff) | |
download | podman-5771f822607214f7b9b61204c82d9f7eb228b6bb.tar.gz podman-5771f822607214f7b9b61204c82d9f7eb228b6bb.tar.bz2 podman-5771f822607214f7b9b61204c82d9f7eb228b6bb.zip |
Merge pull request #13857 from rhatdan/logs
Fix --tail log on restart problem
-rw-r--r-- | libpod/container_log_linux.go | 3 | ||||
-rw-r--r-- | test/system/035-logs.bats | 28 |
2 files changed, 28 insertions, 3 deletions
diff --git a/libpod/container_log_linux.go b/libpod/container_log_linux.go index d96647e51..deb726526 100644 --- a/libpod/container_log_linux.go +++ b/libpod/container_log_linux.go @@ -209,9 +209,6 @@ func (c *Container) readFromJournal(ctx context.Context, options *logs.LogOption containerCouldBeLogging = true case events.Exited: containerCouldBeLogging = false - if doTail { - doTailFunc() - } } continue } diff --git a/test/system/035-logs.bats b/test/system/035-logs.bats index db50c8f8c..e38cdb383 100644 --- a/test/system/035-logs.bats +++ b/test/system/035-logs.bats @@ -30,6 +30,34 @@ load helpers run_podman rm $cid } +function _log_test_tail() { + local driver=$1 + + run_podman run -d --log-driver=$driver $IMAGE sh -c "echo test1; echo test2" + cid="$output" + + run_podman logs --tail 1 $cid + is "$output" "test2" "logs should only show last line" + + run_podman restart $cid + + run_podman logs --tail 1 $cid + is "$output" "test2" "logs should only show last line after restart" + + run_podman rm $cid +} + +@test "podman logs - tail test, k8s-file" { + _log_test_tail k8s-file +} + +@test "podman logs - tail test, journald" { + # We can't use journald on RHEL as rootless: rhbz#1895105 + skip_if_journald_unavailable + + _log_test_tail journald +} + function _additional_events_backend() { local driver=$1 # Since PR#10431, 'logs -f' with journald driver is only supported with journald events backend. |