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

[cli] detect number of available CPU shares from cgroups #600

Merged
merged 1 commit into from
Feb 19, 2018

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Feb 15, 2018

Thanks @jmprusi

Looks like kubernetes exposes number of available milicores as CPU shares. This value is used only when running on kubernetes to prevent misdetection as CPU shares can be any arbitrary number as it is just relative weight.

From https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/#how-pods-with-resource-limits-are-run:

The spec.containers[].resources.requests.cpu is converted to its core value, which is potentially fractional, and multiplied by 1024. The greater of this number or 2 is used as the value of the --cpu-shares flag in the docker run command.

BTW default value is 1024:

$ docker run alpine cat /sys/fs/cgroup/cpu/cpu.shares
1024

Copy link
Contributor

@jmprusi jmprusi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Although I'm still not totally convinced by the ratio of 1024 CPU shares = 1 worker

We can improve this later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants