Skip to content
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

Cgroup2: remove bogus assumptions about cgroup mounts #247

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions granulate_utils/linux/cgroups/cgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,9 @@ def find_v2_hierarchy(resolve_host_root_links: bool = True) -> Optional[str]:
"""
Finds the mounted unified hierarchy for cgroup v2 controllers.
"""
cgroup2_mounts = [
mount for mount in iter_mountinfo(1) if mount.filesystem_type == "cgroup2" and mount.mount_source == "cgroup2"
]
cgroup2_mounts = [mount for mount in iter_mountinfo(1) if mount.filesystem_type == "cgroup2"]
if not cgroup2_mounts:
return None
if len(cgroup2_mounts) > 1:
raise Exception("More than one cgroup2 mount found!")
path = cgroup2_mounts[0].mount_point
if resolve_host_root_links:
path = ns.resolve_host_root_links(path)
Expand Down
6 changes: 1 addition & 5 deletions granulate_utils/linux/cgroups_v2/cgroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,9 @@ def _find_v2_hierarchy() -> Optional[tuple[str, str]]:
"""
Finds the mounted unified hierarchy for cgroup v2 controllers.
"""
cgroup2_mounts = [
mount for mount in iter_mountinfo(1) if mount.filesystem_type == "cgroup2" and mount.mount_source == "cgroup2"
]
cgroup2_mounts = [mount for mount in iter_mountinfo(1) if mount.filesystem_type == "cgroup2"]
if not cgroup2_mounts:
return None
if len(cgroup2_mounts) > 1:
raise Exception("More than one cgroup2 mount found!")
path = cgroup2_mounts[0].mount_point
path = ns.resolve_host_root_links(path)
mount_root = cgroup2_mounts[0].root
Expand Down
Loading