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

os.cpus() failing on lxc containers setting cpuset.cpus to less than the host cpu count #6252

Closed
ardenpm opened this issue Apr 18, 2016 · 2 comments
Labels
confirmed-bug Issues with confirmed bugs. libuv Issues and PRs related to the libuv dependency or the uv binding.

Comments

@ardenpm
Copy link

ardenpm commented Apr 18, 2016

  • Version: 4.4.3 and 5.10.1
  • Platform: Linux 3.19.0-42-generic Improve repo description #48~14.04.1-Ubuntu SMP Fri Dec 18 10:24:49 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux (inside an LXC container)
  • Subsystem: os

When running inside an LXC container with cgroups setup to restrict cpuset.cpus to something less than the number of CPUs in the host machine (very common with cloud providers), accessing os.cpus() will give the following:

node: ../deps/uv/src/unix/linux-core.c:746: read_times: Assertion `num == numcpus' failed.
Aborted

To reproduce you will need to run node inside an LXC container with the appropriate cpuset.cpus setting. You can then reproduce with this command:

node -e "var cpuCount = require('os').cpus().length;"

Because it triggers an assertion failure with an an abort it can't be caught in a try/catch in JavaScript and there really isn't a way to know if it will fail prior to calling it. A common use case for this would be getting the CPU count to use with the cluster module to determine how many instances to run.

While it may not be possible to address the underlying issue it would be helpful it if failed in a way that could be caught in a try/catch so code could be written to use sensible defaults or an alternative method in the event of failure.

@mscdex mscdex added libuv Issues and PRs related to the libuv dependency or the uv binding. confirmed-bug Issues with confirmed bugs. labels Apr 18, 2016
@mscdex
Copy link
Contributor

mscdex commented Apr 18, 2016

This was fixed in libuv v1.9.0 (specifically this commit), which is only in node v6 so far. I'm not sure about backporting though.

@bnoordhuis
Copy link
Member

#5994 is the libuv upgrade and it's been tagged for back-porting to v4.x and v5.x. I'll close, the next minor (not patch) release on those branches will have the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. libuv Issues and PRs related to the libuv dependency or the uv binding.
Projects
None yet
Development

No branches or pull requests

3 participants