-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Add cpu_count, cpu_percent, nano_cpus parameters to container HostConfig. #1570
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
Conversation
Signed-off-by: Alexey Rokhin <arokhin@mail.ru>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking the time to submit a PR!
There's a couple of flake8
failures that need to be fixed:
tests/unit/api_container_test.py:1183:80: E501 line too long (82 > 79 characters)
tests/unit/dockertypes_test.py:175:1: W293 blank line contains whitespace
Once those comments are addressed we should be good to go 👍
docker/models/containers.py
Outdated
cap_add (list of str): Add kernel capabilities. For example, | ||
``["SYS_ADMIN", "MKNOD"]``. | ||
cap_drop (list of str): Drop kernel capabilities. | ||
cpu_count (int): CPU count (Windows only). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace with:
Number of usable CPUs (Windows only).
docker/models/containers.py
Outdated
``["SYS_ADMIN", "MKNOD"]``. | ||
cap_drop (list of str): Drop kernel capabilities. | ||
cpu_count (int): CPU count (Windows only). | ||
cpu_percent (int): CPU percent (Windows only). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please replace with:
Usable percentage of the available CPUs (Windows only).
docker/models/containers.py
Outdated
cpu_quota (int): Microseconds of CPU time that the container can | ||
get in a CPU period. | ||
cpu_shares (int): CPU shares (relative weight). | ||
cpus (float): Number of CPUs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's conform with the API here and use
nano_cpus
(int): CPU quota in units of 10-9 CPUs.
docker/types/containers.py
Outdated
if version_lt(version, '1.25'): | ||
raise host_config_version_error('cpus', '1.25') | ||
|
||
self['NanoCpus'] = int(1000000000 * cpus) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's have nano_cpus
be the parameter instead, limit the acceptable types to int
and avoid float
uncertainty altogether.
…omments for new parameters are changed. Signed-off-by: Alexey Rokhin <arokhin@mail.ru>
@shin- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
Preparation for docker/compose#4582 |
Hi.
I've recreated request because of my troubles with merging
Added ability to set new cpu parameters (cpu_count, cpu_percent, cpus) for container.
Signed-off-by: Alexey Rokhin arokhin@mail.ru