runc update: fix updating swap for cgroup v2#4357
Merged
AkihiroSuda merged 2 commits intoopencontainers:mainfrom Nov 1, 2024
Merged
runc update: fix updating swap for cgroup v2#4357AkihiroSuda merged 2 commits intoopencontainers:mainfrom
AkihiroSuda merged 2 commits intoopencontainers:mainfrom
Conversation
rata
reviewed
Jul 23, 2024
Member
rata
left a comment
There was a problem hiding this comment.
This mostly LGTM. Left some comments, mainly about tests.
On a quick look, it seems crun does the same: https://github.com/containers/crun/blob/main/src/libcrun/cgroup-resources.c#L711
Barakmor1
reviewed
Jul 25, 2024
rata
approved these changes
Aug 22, 2024
Member
rata
left a comment
There was a problem hiding this comment.
LGTM, thanks!
I slightly prefer the version with two ifs, but this is clear anyways, it is a nit.
e1acf39 to
707ee6d
Compare
Contributor
Author
|
For ease of review, I've split this into two commits. |
rata
approved these changes
Sep 13, 2024
Member
rata
left a comment
There was a problem hiding this comment.
LGTM
@kolyshkin thanks for splitting in 2 commits, it makes it really straight-forward to review :)
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>
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>
707ee6d to
732806e
Compare
Contributor
Author
|
@AkihiroSuda @lifubang this is a fix that did not made its way into v1.2.0. I would still like to merge it and then open a backport to release-1.2 branch. |
Merged
AkihiroSuda
approved these changes
Nov 1, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This allows to do
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.
While at it, improve some comments in the code, and revise the unit test.
Fixes: c86be8a ("cgroupv2: fix setting MemorySwap") aka #2288