[#26065] Add cgroup v2 support#34883
Conversation
Signed-off-by: Megmeehey <megmeehey@gmail.com>
|
Thank you for your proposed contribution! This PR has a valid DCO. The relevant team for this area will confirm the design of the implementation choices. Note that while it would be nice to cover the new code with tests somehow, apparently, we don't have good coverage for the existing code. For example, we don't test accessing specific file paths. The team will decide if it's a blocker. @Megmeehey, meanwhile, can you look into making an integration test (maybe with mocks for system files)? FTR, a PR that introduced cgroups v1: |
|
Hmm... From my perspective an integration test here would have limited value. The cgroup memory files only expose a single number, so there’s no complex parsing to validate. A feasible way to add a test I see would be to introduce another constructor that accepts file paths for cgroup v1 and v2. If there is a need for such a test, here is what I come up with: 1dcf88c |
|
@Megmeehey Good points, thanks for looking into that. |
|
We're considering this feature for Gradle 9.3 and will get back to you in a few weeks. |
Any chance to see this back-ported ? |
mlopatkin
left a comment
There was a problem hiding this comment.
My understanding of cgroups is rather shallow, but it looks like we'll serve only a limited number of use cases here (no child groups, no custom mount points). It should be enough for a typical container where the limit is applied to the whole container. Nevertheless, it is as complete as our v1 support is today.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
The following builds have passed: |
|
@bot-gradle test this |
This comment has been minimized.
This comment has been minimized.
|
The following builds have failed: |
|
WARN: Based on labels, this pull request addresses notable issue but no changes to release note found. |
|
This would be nice if this was backported to Gradle 8.14. |
Fixes #26065
Context
Gradle currently only respects cgroup v1 memory limits and ignores cgroup v2.
As a result, when running in a k8s pod on a cgroup v2 host, Gradle can not detect available memory and limits, therefore it keeps idle processes alive, assuming it owns all node memory, and that leads to pod being killed by OOM killer.
This PR adds cgroup v2 support: Gradle now reads /sys/fs/cgroup/memory.current and /sys/fs/cgroup/memory.max, same way it did with v1.
Related doc: https://docs.kernel.org/admin-guide/cgroup-v2.html
Contributor Checklist
<subproject>/src/integTest) to verify changes from a user perspective.<subproject>/src/test) to verify logic../gradlew sanityCheck../gradlew <changed-subproject>:quickTest.Reviewing cheatsheet
Before merging the PR, comments starting with