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

Cgroupsv2 container #1529

Merged
merged 5 commits into from
Sep 29, 2023
Merged

Cgroupsv2 container #1529

merged 5 commits into from
Sep 29, 2023

Conversation

kanderson250
Copy link
Contributor

Resolves #1358

This PR adds support for getting the containerId from a docker container with Linux cgroup v2.

Previously, the containerId was grabbed from proc/self/cgroup for containers with cgroup V1. Now, the id is grabbed from proc/self/mountinfo, with fallthrough to proc/self/cgroup if that file is missing.

  • This is the widely accepted approach for now, though the API is expected to change and a long-term solution is supposedly in the works.
  • The current implementation is based on best-effort research towards the contents of proc/self/mountinfo. Because this solution is a bit hacky, there isn't clear documentation about what's supposed to be in there in different environments/providers. The matching logic may need to be updated in the future.

@codecov-commenter
Copy link

Codecov Report

Merging #1529 (f968855) into main (2c20813) will decrease coverage by 0.01%.
Report is 8 commits behind head on main.
The diff coverage is 77.77%.

@@             Coverage Diff              @@
##               main    #1529      +/-   ##
============================================
- Coverage     70.60%   70.59%   -0.01%     
- Complexity     9745     9753       +8     
============================================
  Files           813      814       +1     
  Lines         39264    39299      +35     
  Branches       5962     5968       +6     
============================================
+ Hits          27723    27744      +21     
- Misses         8856     8864       +8     
- Partials       2685     2691       +6     
Files Coverage Δ
...in/java/com/newrelic/agent/utilization/CGroup.java 100.00% <100.00%> (ø)
...ava/com/newrelic/agent/utilization/DockerData.java 80.00% <75.00%> (-4.10%) ⬇️

... and 11 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Contributor

@jtduffy jtduffy left a comment

Choose a reason for hiding this comment

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

2 minor nits. Nice test coverage!

@kanderson250 kanderson250 merged commit 510c9c9 into main Sep 29, 2023
103 checks passed
@kanderson250 kanderson250 deleted the cgroupsv2-containerID branch September 29, 2023 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Support cgroup v2 for getting container ID
3 participants