Files
podman/test/system/helpers.systemd.bash
Giuseppe Scrivano 751ba07a76 libpod: improve check to create conmon cgroup
commit 1951ff168a63157fa2f4711fde283edfc4981ed3 introduced a check so
that conmon is not moved to a new cgroup when podman is running inside
of a systemd service.  This is helpful to integrate podman in systemd
so that the spawned conmon lives in the same cgroup as the service
that created it.

Unfortunately this breaks when podman daemon is running in a systemd
service since the same check is in place thus all the conmon processes
end up in the same cgroup as the podman daemon.  When the podman
daemon systemd service stops the conmon processes are also terminated
as well as the containers they monitor.

Improve the check to exclude podman running as a daemon.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2052697

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-06-15 15:43:12 +02:00

35 lines
687 B
Bash

# -*- bash -*-
#
# BATS helpers for systemd-related functionality
#
# podman initializes this if unset, but systemctl doesn't
if [ -z "$XDG_RUNTIME_DIR" ]; then
if is_rootless; then
export XDG_RUNTIME_DIR=/run/user/$(id -u)
fi
fi
# For tests which write systemd unit files
UNIT_DIR="/run/systemd/system"
_DASHUSER=
if is_rootless; then
UNIT_DIR="${XDG_RUNTIME_DIR}/systemd/user"
# Why isn't systemd smart enough to figure this out on its own?
_DASHUSER="--user"
fi
mkdir -p $UNIT_DIR
systemctl() {
command systemctl $_DASHUSER "$@"
}
journalctl() {
command journalctl $_DASHUSER "$@"
}
systemd-run() {
command systemd-run $_DASHUSER "$@";
}