mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
d57f5bb286
Commit 18ebc51b3cc3 "Reset Swap when memory is set to unlimited (-1)" added handling of the case when a user updates the container limits to set memory to unlimited (-1) but do not set any other limits. Apparently, in this case, if swap limit was previously set, kernel fails to set memory.limit_in_bytes to -1 if memory.memsw.limit_in_bytes is not set to -1. What the above commit fails to handle correctly is the request when Memory is set to -1 and MemorySwap is set to some specific limit N (where N > 0). In this case, the value of N is silently discarded and MemorySwap is set to -1 instead. This is wrong thing to do, as the limit set, even if incorrectly, should not be ignored. Fix this by only assigning MemorySwap == -1 in case it was not explicitly set. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>