-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
runc update: fix updating swap for cgroup v2 #4357
Conversation
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.
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
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.
LGTM, thanks!
I slightly prefer the version with two ifs, but this is clear anyways, it is a nit.
e1acf39
to
707ee6d
Compare
For ease of review, I've split this into two commits. |
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.
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 <[email protected]>
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 <[email protected]>
707ee6d
to
732806e
Compare
@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. |
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