Skip to content

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

Open
@demeringo

Description

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#

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    • Status

      Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions