Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --tail log on restart problem #13857

Merged
merged 1 commit into from
Apr 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions libpod/container_log_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
28 changes: 28 additions & 0 deletions test/system/035-logs.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down