Skip to content

[1.2] runc update: fix updating swap for cgroup v2#4501

Merged
kolyshkin merged 2 commits intoopencontainers:release-1.2from
AkihiroSuda:cherrypick-4357
Nov 1, 2024
Merged

[1.2] runc update: fix updating swap for cgroup v2#4501
kolyshkin merged 2 commits intoopencontainers:release-1.2from
AkihiroSuda:cherrypick-4357

Conversation

@AkihiroSuda
Copy link
Copy Markdown
Member

Improve readability of ConvertMemorySwapToCgroupV2Value by switching
from a bunch of if statements to a switch, and adding a comment
describing each case.

No functional change.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit cb9f3d6)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This allows to do

	runc update $ID --memory=-1 --memory-swap=$VAL

for cgroup v2, i.e. set memory to unlimited and swap to a specific
value.

This was not possible because ConvertMemorySwapToCgroupV2Value rejected
memory=-1 ("unlimited"). In a hindsight, it was a mistake, because if
memory limit is unlimited, we should treat memory+swap limit as just swap
limit.

Revise the unit test; add description to each case.

Fixes: c86be8a ("cgroupv2: fix setting MemorySwap")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
(cherry picked from commit 732806e)
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda added the backport/1.2-pr A backport PR to release-1.2 label Nov 1, 2024
@AkihiroSuda AkihiroSuda added this to the 1.2.1 milestone Nov 1, 2024
Copy link
Copy Markdown
Member

@rata rata left a comment

Choose a reason for hiding this comment

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

LGTM

@rata rata mentioned this pull request Nov 1, 2024
Copy link
Copy Markdown
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

lgtm, thanks

@kolyshkin kolyshkin enabled auto-merge November 1, 2024 17:20
@kolyshkin kolyshkin merged commit 3016408 into opencontainers:release-1.2 Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.2-pr A backport PR to release-1.2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants