I’m trying to find the most convenient and maintainable LTTng setups supporting collection of traces generated from a container.
Here is what I’ve tried:
host:
- lttng-sessoind (root/user)
- lttng-relayd (root/user)
container:
- liblttng-ust executable
I create snapshot and live sessions on the host which filter traces containing a specific field. Inside the containers I just generate traces.
To achieve this, I start the container like this:
podman run
-v /var/run/lttng:/var/run/lttng
-v /dev/shm/lttng-ust-wait-8:/dev/shm/lttng-ust-wait-8
-e LTTNG_HOME=/root
image-with-liblttng-ust
The image-with-liblttng-ust
image is any image which has an executable producing traces with liblttng-ust
.
Here is an example of the setup where the lttng-sessiond
is started under a non-root user:
podman run
-v /home/username/.lttng:/var/run/lttng
-v /dev/shm/lttng-ust-wait-8-1000:/dev/shm/lttng-ust-wait-8
-e LTTNG_HOME=/root
image-with-liblttng-ust
The first mount doesn’t look bad, the runtime LTTng directory is mounted to establish communication between lttng-sessiond
and liblttng-ust
, nevertheless it could be enough to mount only /home/username/.lttng/lttng-ust-sock-8
for the maintainability IMO mount of the whole directory is better.
The second mount isn’t that nice, it’s outside the runtime directory, it’s not a directory but a specific shared memory file containing the ABI version and the uid in the name, every LTTng update would require verification of the file name.
I’ve also tried various mount combinations:
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
| HOST RUNDIR | CONTAINER RUNDIR | HOST SHM | CONTAINER SHM | WORKS |
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
| /home/username/.lttng | /root/.lttng | /dev/shm/lttng-ust-wait-8-1000 | /dev/shm/lttng-ust-wait-8-0 | yes |
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
| /home/username/.lttng | /var/run/lttng | /dev/shm/lttng-ust-wait-8-1000 | /dev/shm/lttng-ust-wait-8 | yes |
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
| /var/run/lttng | /var/run/lttng | /dev/shm/lttng-ust-wait-8 | /dev/shm/lttng-ust-wait-8 | yes |
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
| /var/run/lttng | /root/.lttng | /dev/shm/lttng-ust-wait-8 | /dev/shm/lttng-ust-wait-8-0 | no |
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
| /home/username/.lttng | /root/.lttng | /dev/shm/lttng-ust-wait-8-1000 | /dev/shm/lttng-ust-wait-8 | no |
+-----------------------+------------------+--------------------------------+-----------------------------+-------+
Is this a valid approach to enable container support? Are there any better options?