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

File not found: /sys/class/powercap/intel-rapl:0/energy_uj #386

Open
demeringo opened this issue May 21, 2024 · 4 comments
Open

File not found: /sys/class/powercap/intel-rapl:0/energy_uj #386

demeringo opened this issue May 21, 2024 · 4 comments
Labels
bug Something isn't working
Projects

Comments

@demeringo
Copy link
Contributor

demeringo commented May 21, 2024

Bug description

Despite the volume mapping and files being present on host, we have a file not found issue when running scaphandre:dev container.

To Reproduce

# Pull latest dev image on docker host
ubuntu@sd-170423:/$ docker pull hubblo/scaphandre:dev
dev: Pulling from hubblo/scaphandre
Digest: sha256:46c01b947ca80c04f328ef3047839c370cd6bcd58a13d51a516ca4efd77ef97a
Status: Image is up to date for hubblo/scaphandre:dev
docker.io/hubblo/scaphandre:dev

# Verify that RAPL files are present on docker host
ubuntu@sd-170423:/$ ls -al /sys/class/powercap/intel-rapl/intel-rapl:0
total 0
drwxr-xr-x 5 root root    0 Apr  6 14:48 .
drwxr-xr-x 4 root root    0 Apr  6 14:48 ..
-r-------- 1 root root 4096 Apr  6 14:48 constraint_0_max_power_uw
-r-------- 1 root root 4096 Apr  6 14:48 constraint_0_name
-rw------- 1 root root 4096 Apr  6 14:48 constraint_0_power_limit_uw
-rw------- 1 root root 4096 Apr  6 14:48 constraint_0_time_window_us
-r-------- 1 root root 4096 Apr  6 14:48 constraint_1_max_power_uw
-r-------- 1 root root 4096 Apr  6 14:48 constraint_1_name
-rw------- 1 root root 4096 Apr  6 14:48 constraint_1_power_limit_uw
-rw------- 1 root root 4096 Apr  6 14:48 constraint_1_time_window_us
lrwxrwxrwx 1 root root    0 Apr  6 14:48 device -> ../../intel-rapl
-rw-r--r-- 1 root root 4096 Apr  6 14:48 enabled
-r-------- 1 root root 4096 Apr  6 14:48 energy_uj
drwxr-xr-x 3 root root    0 Apr  6 14:48 intel-rapl:0:0
drwxr-xr-x 3 root root    0 Apr  6 14:48 intel-rapl:0:1
-r-------- 1 root root 4096 Apr  6 14:48 max_energy_range_uj
-r--r--r-- 1 root root 4096 Apr  6 14:48 name
drwxr-xr-x 2 root root    0 Apr  6 14:48 power
lrwxrwxrwx 1 root root    0 Apr  6 14:48 subsystem -> ../../../../../class/powercap
-rw-r--r-- 1 root root 4096 Apr  6 14:48 uevent

# Run container
docker run -v /sys/class/powercap:/sys/class/powercap -v /proc:/proc -ti hubblo/scaphandre:dev stdout -t 5
Scaphandre stdout exporter
Sending ⚡ metrics
Measurement step is: 2s
scaphandre::sensors: Could'nt read record from /sys/class/powercap/intel-rapl:0/energy_uj, error was: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Host:   0 W from
Top 5 consumers:
Power           PID     Exe
No processes found yet or filter returns no value.
------------------------------------------------------------

scaphandre::sensors: Could'nt read record from /sys/class/powercap/intel-rapl:0/energy_uj, error was: Os { code: 2, kind: NotFound, message: "No such file or directory" }
Host:   0 W from
Top 5 consumers:
Power           PID     Exe
0 W     527053  ""
0 W     2003239 "/usr/local/bin/scaphandre"
0 W     1160258 ""
0 W     2003240 ""
0 W     323     ""
------------------------------------------------------------

Expected behavior

Seems to work when container is run in --privileged mode.

# Launch docker with --privileged flag
ubuntu@sd-170423:/$ docker run --privileged -v /sys/class/powercap:/sys/class/powercap -v /proc:/proc -ti hubblo/scaphandre:
dev stdout -t 5
Scaphandre stdout exporter
Sending ⚡ metrics
Measurement step is: 2s
Host:   0 W from
        package         core            dram
Top 5 consumers:
Power           PID     Exe
No processes found yet or filter returns no value.
------------------------------------------------------------

Host:   21.177587 W from
        package         core            dram
Socket0 13.206961 W |   4.641535 W      7.973106 W

Top 5 consumers:
Power           PID     Exe
0.060995355 W   2003383 "/usr/local/bin/scaphandre"
0.012199071 W   917     "/usr/lib/systemd/systemd-resolved"
0 W     1019    "/usr/sbin/agetty (deleted)"
0 W     47      ""
0 W     34      ""
------------------------------------------------------------

Screenshots

Environment

  • Linux distribution version: Ubuntu 20.04.6 LTS
  • Kernel version (output of uname -r): 5.4.0-174-generic
  • Docker version 26.1.1, build 4cf5afa
ubuntu@sd-170423:/$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal
ubuntu@sd-170423:/$ uname -r
5.4.0-174-generic
ubuntu@sd-170423:/$ docker --version
Docker version 26.1.1, build 4cf5afa

Additional context

  • Running docker as root (but withour --privileged flag) does not solve the issue
  • Mounting volumes with the --mount command (instead) of --volume does not solve the issue
  • When looking inside a running container (without the --privileged flag) the links toward the powercap subdirectories are created but appear broken (pointing to nothing).
# Inside a non priviledged container

ubuntu@sd-170423:/$ sudo docker run -v /sys/class/powercap:/sys/class/powercap -v /proc:/proc -ti --entrypoint /bin/bash hub
blo/scaphandre:dev

# We have broken  links
root@384fbcdad37d:/app# ls -al /sys/class/powercap
total 0
drwxr-xr-x  2 root root 0 Apr  6 14:48 .
drwxr-xr-x 69 root root 0 May 21 11:42 ..
lrwxrwxrwx  1 root root 0 Apr  6 14:48 intel-rapl -> ../../devices/virtual/powercap/intel-rapl
lrwxrwxrwx  1 root root 0 Apr  6 14:48 intel-rapl:0 -> ../../devices/virtual/powercap/intel-rapl/intel-rapl:0
lrwxrwxrwx  1 root root 0 Apr  6 14:48 intel-rapl:0:0 -> ../../devices/virtual/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:0
lrwxrwxrwx  1 root root 0 Apr  6 14:48 intel-rapl:0:1 -> ../../devices/virtual/powercap/intel-rapl/intel-rapl:0/intel-rapl:0:1
root@384fbcdad37d:/app# ls -al /sys/class/powercap/../../devices/virtual/powercap/intel-rapl
ls: cannot access '/sys/class/powercap/../../devices/virtual/powercap/intel-rapl': No such file or directory

# Mounted powercap directory appears empty
root@384fbcdad37d:/app# ls -al /sys/class/powercap/../../devices/virtual/powercap
total 0
drwxrwxrwt  2 root root 40 May 21 11:42 .
drwxr-xr-x 20 root root  0 May 21 11:42 ..
root@384fbcdad37d:/app#
@demeringo
Copy link
Contributor Author

To be fair, the use of --privileged mode is mentionned in the doc (but only with Podman and not for Ubuntu).

And I do not remember having to use this flag before (but you know how memory works 🙃).... maybe something changed with a docker or ubuntu update ?

https://hubblo-org.github.io/scaphandre-documentation/tutorials/getting_started.html#running-scaphandre-on-fedora--centos-stream--rhel-or-any-distribution-using-selinux-with-podman

@demeringo
Copy link
Contributor Author

Caution

Running the container as --privileged is likely a bad idea in term of security.
Just mentionned here as a workaround.

@thelo09
Copy link

thelo09 commented Jun 17, 2024

Any fixes?

@ssen85
Copy link

ssen85 commented Jun 18, 2024

I've been facing the same problem. Running the container as privileged works but not otherwise. Is there any update on a fix for this ?

@bpetit bpetit added this to Triage in General Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Triage
General
Triage
Development

No branches or pull requests

3 participants