moby icon indicating copy to clipboard operation
moby copied to clipboard

Fix update memory without memoryswap

Open IceCodeNew opened this issue 1 year ago • 1 comments

- What I did An attempt to update memory without memoryswap on a UNIX container that has no previous memoryswap setup would cause a confusing warning says Memory limit should be smaller than already set memoryswap limit

This commit fixes support for both situations of setting memory constraints:

  • specify memory without memory-swap, while the latter one defaults to 0
  • specify memory without memory-swap, while the latter one was set to -1

- How I did it Made an additional check for the previous value of the memory-swap limit, to stop sending users confusing warnings.

- How to verify it Refer to: https://github.com/docker/cli/blob/8ed44f916fa908a04f03f69369bc2a16e0db7cc9/docs/reference/run.md#user-memory-constraints

docker run --name pause -d registry.k8s.io/pause:latest
docker update -m 10M pause
# Memory should be 10M, and MemorySwap should be 20M
docker inspect pause | grep -F Memory

# This change should be declined
docker update -m 100M pause


docker rm -f pause
docker run --name pause -d registry.k8s.io/pause:latest
docker update --memory-swap -1 pause
docker update -m 10M pause
# Memory should be 10M, and MemorySwap should be -1
docker inspect pause | grep -F Memory

- Description for the changelog

Fix update memory without memoryswap

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

IceCodeNew avatar May 29 '24 17:05 IceCodeNew

Hi @thaJeztah ,

I hope this message finds you well. I'm writing to inquire if it would be appropriate to assign this PR to you, as it appears you were the last person to make changes to this file.

I apologize for the interruption, but I believe this change could be quite beneficial in eliminating a confusing error message. Would you be willing to take a look at it when you have a moment?

Thank you for your time and consideration.

Best regards,

IceCodeNew avatar Aug 14 '24 03:08 IceCodeNew