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(detector-container): properly detect container ID when using Podman #2448

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

sjinks
Copy link
Contributor

@sjinks sjinks commented Sep 23, 2024

Which problem is this PR solving?

When using Podman, the container detector is unable to determine the ID of the container. This happens because the detector expects /containers/<container ID> substring in the mountinfo but Podman uses /overlay-containers/<container ID> instead.

For example:

$ podman run -it --rm alpine grep hostname /proc/self/mountinfo
4282 4276 0:94 /containers/overlay-containers/b9bb2fc96c57ef741ffbaaed3c0ac16a70705ba27443ce1a7d73554c9a63d125/userdata/hostname /etc/hostname rw,nosuid,nodev,relatime - tmpfs tmpfs rw,size=6557728k,nr_inodes=1639432,mode=700,uid=1000,gid=1000,inode64

For docker:

$ docker run -it --rm alpine grep hostname /proc/self/mountinfo
4204 4195 259:2 /var/lib/docker/containers/0848110e7e6a6fe6317d104e099286860b03962119a1a124d9dd6ec4c4dc4b11/hostname /etc/hostname rw,relatime - ext4 /dev/nvme0n1p2 rw,errors=remount-ro

Short description of the changes

Fix Container ID detection in Podman containers

@sjinks sjinks requested a review from a team as a code owner September 23, 2024 22:07
Copy link

linux-foundation-easycla bot commented Sep 23, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: sjinks / name: Volodymyr Kolesnykov (2645245, 8ec2559)
  • ✅ login: pichlermarc / name: Marc Pichler (7e0fd2b)
  • ✅ login: david-luna / name: David Luna (4adab85)

Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.74%. Comparing base (d11efb3) to head (7e0fd2b).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2448   +/-   ##
=======================================
  Coverage   90.74%   90.74%           
=======================================
  Files         156      156           
  Lines        7723     7723           
  Branches     1588     1588           
=======================================
  Hits         7008     7008           
  Misses        715      715           
Files with missing lines Coverage Δ
...ector-container/src/detectors/ContainerDetector.ts 95.31% <100.00%> (ø)
...resource-detector-container/src/detectors/utils.ts 93.93% <100.00%> (ø)

@david-luna
Copy link
Contributor

@sjinks it seems you have a linting issue

@sjinks
Copy link
Contributor Author

sjinks commented Oct 10, 2024

@david-luna I have fixed them now

@pichlermarc pichlermarc merged commit ad560df into open-telemetry:main Oct 14, 2024
20 checks passed
@dyladan dyladan mentioned this pull request Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants