Skip to content
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

Fix cgroup path computation #399

Merged
merged 1 commit into from
Jul 21, 2021
Merged

Fix cgroup path computation #399

merged 1 commit into from
Jul 21, 2021

Conversation

azertyfun
Copy link

In testing scenarios, the process path is not necessarily /proc/<pid>/cgroup, but fixtures/<pid>/cgroup or similar.

I have encountered this issue while trying to extend process-exporter to support cgroups, which worked fine in practiced but failed the tests because it attempted to read /proc/<pid>/cgroup instead of ../fixtures/<pid>/cgroup.

-> The fix is trivial: p.path("cgroup") already exists and is the more flexible alternative for cases where the proc directory isn't /proc/. This makes behavior consistent with the rest of the library as far as I can tell.

I haven't found anywhere else that needs fixing by grepping on Sprintf.*PID.


Tangentially related but I couldn't figure out how to test my changes to process-exporter with my fork of procps without changing all imports to point to my fork and updating my fork's master to rename all imports prometheus/procfs to azertyfun/procfs. What am I doing wrong? Surely importing my fork should be easier?

In testing scenarios, the process path is not necessarily
`/proc/<pid>/cgroup`, but `fixtures/<pid>/cgroup` or similar.

Signed-off-by: Nathan Monfils <nmo@escaux.com>
Copy link
Member

@SuperQ SuperQ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice catch.

azertyfun added a commit to azertyfun/process-exporter that referenced this pull request Jul 20, 2021
This simply exposes the procps method to get a process' cgroups.

If the cgroup is not available, we simply return an empty array as this
can commonly happen on older kernels using the v1 cgroups (found at
`/proc/self/cgroups` instead of `/proc/self/cgroup`).

This commit still needs to be updated with the version of procfs which
implements prometheus/procfs#399, as otherwise
the tests will fail due to unsupported fixtures.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants