10000 Implemented memory and CPU limits for LCOW. by notanaverageman · Pull Request #37296 · moby/moby · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Implemented memory and CPU limits for LCOW. #37296

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

Merged
merged 1 commit into from
Feb 4, 2019

Conversation

notanaverageman
Copy link
Contributor

Signed-off-by: Yusuf Tarık Günaydın yusuf_tarik@hotmail.com

- What I did
Added implementation of --memory and --cpu switches for LCOW.

- How I did it
Filled the Resources object in spec.Windows for both Windows and Linux by separating it into a new method. Also separated the code that fills the CPU and memory part of the hcsshim configuration and called it for both Windows and Linux.

- How to verify it
docker run -it --memory=2G --cpus=8 alpine sh -c "nproc && cat /proc/meminfo"

- Description for the changelog

Added memory and CPU limits for LCOW.

- A picture of a cute animal (not mandatory but encouraged)

@mlaventure
Copy link
Contributor

You need to run gofmt and goimport on the modified files.

Also, could you add unit tests?

@notanaverageman
Copy link
Contributor Author

I use VSCode and it automatically applies those tools on save. I cannot see any formatting or importing issues. If there is, can yo point me to it?

For unit testing, I can add test to https://github.com/moby/moby/blob/master/integration-cli/docker_cli_run_test.go, however, the docs says it is deprecated. I couldn't find a way to launch LCOW test from the new integration test suite.

By the way #37294 is very similar to this one and it is getting merged without any tests.

@thaJeztah
Copy link
Member

Yeah, LCOW doesn't currently run in CI here (I think that's being worked on)

ping @johnstep @AntaresS ?

@yusuf-gunaydin looks like this needs a rebase (it shows there's a merge conflict); can you update the PR?

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/moby/moby/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "lcow_limits" git@github.com:yusuf-gunaydin/moby.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842354292296
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Jun 26, 2018
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Jun 26, 2018
@notanaverageman
Copy link
Contributor Author

@thaJeztah Resolved the conflict. However, I am not sure why Janky build fails. The failing test is TestSwarmClusterRotateUnlockKey and it doesn't seem to be related to this PR.

@lahma
Copy link
lahma commented Aug 17, 2018

May I enquire the status of this? I tested @yusuf-gunaydin 's branch and it indeed resolved the memory starvation we had by allowing more memory to be assigned via command line.

@thaJeztah
Copy link
Member

ping @johnstep @jhowardmsft PTAL

@yusuf-gunaydin looks like there's a merge-commit in this PR; could you rebase your branch, and squash the commits down to a single commit? Let me know if you need help doing so

@lahma
Copy link
lahma commented Aug 20, 2018

FYI, the memory limit actually works, but CPU doesn't. the configuration is valid and goes to daemon as expected, but Windows doesn't yet handle the parameter properly. So when --cpu 20 is used, container always only sees 1.

@codecov
Copy link
codecov bot commented Aug 22, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@50e63ad). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #37296   +/-   ##
=========================================
  Coverage          ?    36.6%           
=========================================
  Files             ?      610           
  Lines             ?    45237           
  Branches          ?        0           
=========================================
  Hits              ?    16561           
  Misses            ?    26394           
  Partials          ?     2282

@notanaverageman
Copy link
Contributor Author

@thaJeztah I have applied the rebase. I assume the failing builds are unrelated as other pull requests fail with the same errors.

@lahma I tested with this command and result is correct:

docker run --rm -it --cpus=8 alpine sh -c "nproc"
8

This PR changes the limits on the created Hyper-V machine. I don't think there is an issue with Windows not supporting multiple CPUs with Hyper-V.

@lahma
Copy link
lahma commented Aug 22, 2018

@yusuf-gunaydin sorry, I left out the fact that my use case is with Windows Server 2019 Preview (build 17733 if I remember right). So it has lacking support for the CPU parameter at least per my testing (/proc/cpuinfo). Bleeding edge with quirks...

@lowenna
Copy link
Member
lowenna commented Aug 22, 2018

@beweedon just in case. As mentioned offline

@orest-gulman
Copy link
orest-gulman commented Jan 28, 2019

In last docker edge version, the issue still exist.
PS C:\scripts> docker run -it --memory=2G alpine sh
/ # free -m
total used free shared buffers cached
Mem: 962 104 858 18 0 18
-/+ buffers/cache: 85 876
Swap: 0 0 0

@lowenna
Copy link
Member
lowenna commented Jan 28, 2019

@orest-gulman Yes, that will be the case until this PR has been merged into moby/moby and docker-ce/ee takes the patch :/

@movainer
Copy link

@johnstep & @thaJeztah If i can add my 2c, can this go in?

@lowenna
Copy link
Member
lowenna commented Feb 1, 2019

@yusuf-gunaydin I can only apologise on behalf of other maintainers that this seems to keep being ignored. Unfortunately it needs another rebase. @thaJeztah @johnstep @cpuguy83 what I can I do to convince other maintainers that this is required (for both local inprocess and the containerd work)? There’s no shortage of people who have indicated it’s a blocking issue for them, and it’s been ongoing for many many months now.

Copy link
Member
@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM, but needs a rebase.

@lowenna
Copy link
Member
lowenna commented Feb 2, 2019

Thanks @cpuguy83. @yusuf-gunaydin If you can rebase, we should be able to get this merged. Thanks!

Signed-off-by: Yusuf Tarık Günaydın <yusuf_tarik@hotmail.com>
@notanaverageman
Copy link
Contributor Author

@jhowardmsft Rebased again. Experimental build failed with a swarm test saying that context deadline exceeded. I think it's not related to this one, but I am not sure.

@jazzdelightsme
Copy link

Thank you @vdemeester! (and @yusuf-gunaydin!)

@orest-gulman
Copy link
orest-gulman commented Feb 5, 2019

@orest-gulman Yes, that will be the case until this PR has been merged into moby/moby and docker-ce/ee takes the patch :/

@jhowardmsft Now we need to wait for an update docker ce?, thanks

@richardgavel
Copy link

Do you know if there's anything we can track on Docker's side to know they took the merge?

@lowenna
Copy link
Member
lowenna commented Feb 6, 2019

Not that I know of. It will be In master.dockerproject.org binaries now. CE and EE will probably take a cut in March for their 19.03 release. I doubt this would be backported to 18.09 or earlier as LCOW remains an experimental feature. @thaJeztah may know a better way to track than I do, but I think what I said is pretty accurate.

@notanaverageman notanaverageman deleted the lcow_limits branch February 6, 2019 06:22
@Iristyle
Copy link
Iristyle commented Feb 6, 2019

docker-ce repository has an engine directory at https://github.com/docker/docker-ce/tree/master/components/engine which contains the fork of the moby project that lives in https://github.com/docker/engine

docker-ce is pulling in commit docker-archive/docker-ce@c385bd1 as of 2/6/2019, which, according to the commit, represents commit f8e29fd from this repo

f8e29fd includes the merge of this PR (#37296), so the nightly builds from master at https://master.dockerproject.com/windows/x86_64/docker.zip should now contain this feature (validating now)

For those interested in running / configuring nightlies, there are some instructions for installing this build (and configuring LCOW) that I've documented here:
https://github.com/puppetlabs/pupperware/blob/master/README-windows.md#install-the-docker-nightly-build

UPDATE: Downloaded master nightly builds from Feb 5 2019, and it represents commit https://github.com/docker/engine/commits/f091a8d which includes this change.

Client:
 Version:           master-dockerproject-2019-02-05
 API version:       1.40
 Go version:        go1.11.5
 Git commit:        896ff57b
 Built:             Tue Feb  5 23:51:43 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server:
 Engine:
  Version:          master-dockerproject-2019-02-05
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.11.5
  Git commit:       f091a8d
  Built:            Tue Feb  5 23:59:30 2019
  OS/Arch:          windows/amd64
  Experimental:     true

@albertony
Copy link

I doubt this would be backported to 18.09 or earlier as LCOW remains an experimental feature.

It would be really nice if you actually would consider backporting, as LCOW in 19.03 seems to require Windows build 1809 (due to pull request #39108, with further explanation here), and some of us will be stuck with Windows build 1803 for some time (corporate managed computer). @thaJeztah have submitted a lot of backport pull requests on docker/engine recently, I would love to see this one included as well!

@waleed-alharthi
Copy link

As far as I can see after compiling moby from source, I am able to get memory limits working even in Docker compose. Think we are just waiting on this to be merged.

Hi, a little late to the party, is this currently possible in compose? What tags to use?

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

Successfully merging this pull request may close these issues.

0