podman logs: read journald with passthrough

The passthrough driver is designed for use in systemd units. By default
we can expect systemd to log the output on journald unless the unit sets
differen StandardOutput/StandardError settings.

At the moment podman logs just errors out when the passthrough driver is
used. With this change we will read the journald for the unit messages.
The logic is actually very similar to the existing one, we just need to
change the filter. We now filter by SYSTEMD_UNIT wich equals to the
contianer cgroup, this allows us the actually filter on a per contianer
basis even when multiple contianers are started in the same unit, i.e.
via podman-kube@.service.

The only difference a user will see is that journald will merge
stdout/err into one stream so we loose the separation there.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger
2023-02-14 15:59:10 +01:00
parent 37352a0c8c
commit 1590c7bf42
4 changed files with 40 additions and 8 deletions

View File

@@ -383,11 +383,15 @@ metadata:
spec:
containers:
- command:
- top
- sh
- -c
- echo a stdout; echo a stderr 1>&2; sleep inf
image: $IMAGE
name: a
- command:
- top
- sh
- -c
- echo b stdout; echo b stderr 1>&2; sleep inf
image: $IMAGE
name: b
EOF
@@ -418,6 +422,10 @@ EOF
for name in "a" "b"; do
run_podman container inspect test_pod-${name} --format "{{.HostConfig.LogConfig.Type}}"
assert $output != "passthrough"
# check that we can get the logs with passthrough when we run in a systemd unit
run_podman logs test_pod-$name
assert "$output" == "$name stdout
$name stderr" "logs work with passthrough"
done
# Add a simple `auto-update --dry-run` test here to avoid too much redundancy