Description
- Version: v12.16.3
- Platform: Ubuntu 18.04 - 5.0.21-5-pve
- Subsystem: os
What steps will reproduce the bug?
Spawn LXC container, load reported in the container (via top or htop) will be correct, while NodeJS reports the hypervisor load:
# uptime; node load.js
09:18:04 up 40 days, 22:06, 3 users, load average: 0.15, 0.32, 0.43
[ 20.83984375, 14.32861328125, 12.10791015625 ]
Code example:
const os = require( 'os' );
var os_loadavg = os.loadavg();
console.log(os_loadavg);
How often does it reproduce? Is there a required condition?
Constantly
What is the expected behavior?
I'd expect the load to be reported correctly
What do you see instead?
Load from hypervisor exposed
Additional information
Environment is LXC, I'd assume it's due to libuv gets the actual information from the hypervisor, and not the container.
Maybe a similar approach to #27170 should be implemented, and allow a fallback to /proc/loadavg
if available.
It's quite common to run applications within LXC, thus it would be nice the os
package returns the correct information as seen by the container itself.
In my specific case, the load on the system is detected, and it will halt the application until load drops - since this is the wrong load returned (higher than the defined limit) the application halts more frequently than it should.