Add the --use_cgroupv2 flag when relevant#121
Merged
Conversation
According to google/nsjail#119, the flag should be passed for NsJail to try to use cgroupv2. This commit will use the /sys/fs/cgroup structure to guess the installed version, and depending on the version add that flag.
HassanAbouelela
approved these changes
Dec 7, 2021
Contributor
HassanAbouelela
left a comment
There was a problem hiding this comment.
Confirmed working on cgroups 1
MarkKoz
reviewed
Dec 7, 2021
Contributor
MarkKoz
left a comment
There was a problem hiding this comment.
I suppose I am late but I'll review this anyway.
Comment on lines
+56
to
+57
| if DEBUG: | ||
| log.info(f"Guessed cgroups version: {version}") |
| def _probe_cgroup_version() -> int: | ||
| """Poll the filesystem and return the guessed cgroup version.""" | ||
| # Right now we check whenever the controller path exists | ||
| version = 2 if CGROUPV2_PROBE_PATH.exists() else 1 |
Contributor
There was a problem hiding this comment.
Ideally this would use statfs to get the filesystem type, but Python doesn't make it easy to perform this syscall unfortunately.
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.
According to google/nsjail#119, the flag should be passed for NsJail to try to use cgroupv2. This commit will use the
/sys/fs/cgroupstructure to guess the installed version, and depending on the version add that flag.I couldn't confirm this actually solves the issue with v2 but at least it doesn't break with v1.