-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Getting a cgroup path from cgroup ID #1500
Comments
Getting filesystem paths through bpf is notoriously tricky b/c you need to take locks. IIUC from following the kernel discussions, the main issue is deadlocks b/c the bpf prog could try to take a lock in an already locked context. @olsajiri probably has the most insight into feasibility of a cgroup_path() helper. cgroup id is just inode # in cgroupfs so one workaround could look like this:
|
Hm @danobi .. it does not make much sense, but my
Code https://github.com/bwplotka/ebpf_exporter/blob/exp/decoder/cgroup.go#L38 (invoking |
@bwplotka It looks like you're using hybrid cgroup1 + cgroup2 setup on your host. I believe under cgroup1, a process may be in multiple cgroups. Under cgroup2, a process may only be in 1 cgroup. |
There is now the |
Is your feature request related to a problem? Please describe.
Use case:
My host machine has multiple running docker containers. Inside a docker container, there is a medic process that can report container health.
I'm looking to extend oomkill.bt to notify the medic process whenever there is an OOM event. bpftrace provides a built-in variable "cgroup" which is a cgroup ID. I'm looking to convert cgroup ID to a full cgroup path. Since the full cgroup path has docker container ID, I can use the path to notify the medic process in the correct container.
Describe the solution you'd like
A new BPF helper function that calls task_cgroup_path
Describe alternative solutions or features you've considered
An alternative is to pass cgroup id to a separate program that can convert cgroup id to cgroup path using a similar approach.
The text was updated successfully, but these errors were encountered: