Switch Swarm Mode services to NanoCpu#39190
Merged
Merged
Conversation
Today `$ docker service create --limit-cpu` configures a containers `CpuPeriod` and `CpuQuota` variables, this commit switches this to configure a containers `NanoCpu` variable instead. Signed-off-by: Olly Pomeroy <[email protected]>
Contributor
|
@ollypom thanks about this and congrats about your first PR to Moby 🎂 |
Contributor
Author
|
@olljanat Thanks :) Do you know who would be best, to tag in to take a look and review this? |
Member
|
hm, nice catch; I looked at this PR and wondered if the actual limits would be set, but looks like this was effectively was just dead code (as container create also does this conversion/calculation) 🤔 Verified that the limits are properly set with this PR; docker service create --name test --limit-cpu=0.5 nginx:alpine
docker exec $(docker ps -q --filter label=com.docker.swarm.service.name=test) sh -c 'cat /sys/fs/cgroup/cpu/cpu.cfs_quota_us /sys/fs/cgroup/cpu/cpu.cfs_period_us'
50000
100000 |
Member
This was referenced May 21, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
- What I did
Today
$ docker service create --limit-cpuconfigures a containersCpuPeriodandCpuQuotavariables, this commit switches this to configure a containersNanoCpuvariable instead to try and fix #33538 and provide support for limiting CPU on Windows Workloads.This change makes
$ docker service create --limit-cputhe same as$ docker run --cpuas the later is supported on windows. https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/resource-controlsThe reason this change was required is because CPU Period is not supported on Windows today:
I have tested this change locally on a Linux machine and it now sets the NanoCPU setting correctly and does not set CPU Period / Quota. Note I haven't actually tested this on a Windows Machine though.
- How I did it
- How to verify it
- Description for the changelog
Support CPU constraints on Windows Swarm Services
- A picture of a cute animal (not mandatory but encouraged)
