The DSD golang library is already able to auto-detect the container ID of the running process by inspecting /proc/self/cgroup.
Unfortunately, this technique stopped working with cgroup v2 which comes with cgroup namespace.
If the running process runs in a non-host cgroup namespace, its visible /proc/self/cgroup will not contain the container ID.
This PR implements an alternative way of finding the container ID in /proc/self/mountinfo.
If we’re using cgroup V1, we can still use the /proc/self/cgroup-based logic.
If we’re in the host cgroup namespace, we can still use the /proc/self/cgroup-based logic.
Otherwise, let’s make a try with /proc/self/mountinfo.
This PR replicates in the DSD golang client library the logic that has been introduced in DataDog/datadog-agent#14045.
The DSD golang library is already able to auto-detect the container ID of the running process by inspecting
/proc/self/cgroup
. Unfortunately, this technique stopped working with cgroup v2 which comes with cgroup namespace. If the running process runs in a non-host cgroup namespace, its visible/proc/self/cgroup
will not contain the container ID. This PR implements an alternative way of finding the container ID in/proc/self/mountinfo
.If we’re using cgroup V1, we can still use the
/proc/self/cgroup
-based logic. If we’re in the host cgroup namespace, we can still use the/proc/self/cgroup
-based logic. Otherwise, let’s make a try with/proc/self/mountinfo
.This PR replicates in the DSD golang client library the logic that has been introduced in DataDog/datadog-agent#14045.