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

Fix update memory without memoryswap #25461

Merged
merged 1 commit into from Aug 9, 2016

Conversation

coolljt0725
Copy link
Contributor

- What I did

fixes #25460

- How I did it

- How to verify it

- Description for the changelog

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

The memory should always be smaller than memoryswap,
we should error out with message that user know how
to do rather than just an invalid argument error if
user update the memory limit bigger than already set
memory swap.

Signed-off-by: Lei Jitang leijitang@huawei.com

If you want update a memory limit bigger than the already set swap memory limit,
you should update swap memroy limit at the same time. If you don't set swap memory
limit on docker create/run but only memory limit, the swap memory is double of
the memory limit.
Copy link
Contributor

Choose a reason for hiding this comment

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

remove the "of" here, or use "double that of", it reads a bit odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks :)

@@ -67,6 +67,12 @@ a running container with kernel memory initialized.
**-m**, **--memory**=""
Memory limit (format: <number><optional unit>, where unit = b, k, m or g)

Note that the memory should be smaller than the already set swap memory limit.
If you want update a memory limit bigger than the already set swap memory limit,
you should update swap memroy limit at the same time. If you don't set swap memory
Copy link
Contributor

Choose a reason for hiding this comment

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

typo "memroy"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

The memory should always be smaller than memoryswap,
we should error out with message that user know how
to do rather than just an invalid argument error if
user update the memory limit bigger than already set
memory swap.

Signed-off-by: Lei Jitang <leijitang@huawei.com>
@justincormack
Copy link
Contributor

LGTM

@@ -283,6 +283,11 @@ func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfi
cResources.CpusetMems = resources.CpusetMems
}
if resources.Memory != 0 {
// if memory limit smaller than already set memoryswap limit and doesn't
// update the memoryswap limit, then error out.
if resources.Memory > cResources.MemorySwap && resources.MemorySwap == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Should this be

if resources.Memory > cResources.MemorySwap &&  resources.Memory > resources.MemorySwap {

To check if a new MemorySwap is set, it's a valid new combination as well?

Copy link
Member

Choose a reason for hiding this comment

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

er, sorry, my example wasn't right, hold on

Copy link
Member

Choose a reason for hiding this comment

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

think this;

if resources.Memory > cResources.MemorySwap &&  (resources.MemorySwap == 0 || resources.Memory > resources.MemorySwap) {

Copy link
Member

Choose a reason for hiding this comment

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

LOL, actually, my first example may be correct

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thaJeztah We already has resources.Memory > resources.MemorySwap validation before we get here in https://github.com/docker/docker/blob/master/daemon/daemon_unix.go#L273. So I think it's ok just check if the memoryswap is set here.

Copy link
Member

Choose a reason for hiding this comment

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

@coolljt0725 ah, makes sense, thanks!

@thaJeztah
Copy link
Member

LGTM

@thaJeztah thaJeztah merged commit 8233e2b into moby:master Aug 9, 2016
@coolljt0725 coolljt0725 deleted the fix_update_mem branch August 10, 2016 01:00
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
The memory should always be smaller than memoryswap,
we should error out with message that user know how
to do rather than just an invalid argument error if
user update the memory limit bigger than already set
memory swap.

cherry-pick from: moby#25461
conflict:
        integration-cli/docker_cli_update_unix_test.go

Signed-off-by: Lei Jitang <leijitang@huawei.com>
liusdu pushed a commit to liusdu/moby that referenced this pull request Oct 30, 2017
Fix update memory without memoryswap

The memory should always be smaller than memoryswap,
we should error out with message that user know how
to do rather than just an invalid argument error if
user update the memory limit bigger than already set
memory swap.

cherry-pick from: moby#25461
conflict:
        integration-cli/docker_cli_update_unix_test.go

Signed-off-by: Lei Jitang <leijitang@huawei.com>


See merge request docker/docker!389
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update memory limit error out with "invalid argument"
4 participants