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
Conversation
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. |
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.
remove the "of" here, or use "double that of", it reads a bit odd.
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.
fixed, thanks :)
96cd3cb
to
a705989
Compare
@@ -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 |
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.
typo "memroy"
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.
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>
a705989
to
9239478
Compare
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 { |
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.
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?
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.
er, sorry, my example wasn't right, hold on
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.
think this;
if resources.Memory > cResources.MemorySwap && (resources.MemorySwap == 0 || resources.Memory > resources.MemorySwap) {
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.
LOL, actually, my first example may be correct
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.
@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.
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.
@coolljt0725 ah, makes sense, thanks!
LGTM |
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>
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
- 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