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

cgroups: fall back to parent cgroup if no child found #152

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion mir-ci/mir_ci/lib/cgroups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import os
import pathlib
import warnings
from typing import Iterator


Expand Down Expand Up @@ -29,7 +30,8 @@ async def get_cgroup_dir(pid: int) -> pathlib.Path:
if path != parent_path:
return path
else:
raise RuntimeError(f"Unable to read cgroup directory for pid: {pid}")
warnings.warn(f"Unable to find child cgroup for pid: {pid}")
return parent_path

@staticmethod
def _get_cgroup_dir_internal(pid: int) -> pathlib.Path:
Expand Down
6 changes: 6 additions & 0 deletions mir-ci/mir_ci/tests/test_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import time
from collections import OrderedDict
from contextlib import suppress
from pathlib import Path
from unittest import IsolatedAsyncioTestCase
from unittest.mock import MagicMock, Mock, call, mock_open, patch

Expand Down Expand Up @@ -309,6 +310,11 @@ async def test_cgroup_path_raises_runtime_error_when_contents_are_none(self, moc
with pytest.raises(RuntimeError, match=f"Unable to find path for process with pid: {os.getpid()}"):
await Cgroup.get_cgroup_dir(12345)

@patch("builtins.open", new_callable=mock_open, read_data="0::path")
async def test_group_path_warns_when_no_child_found(self, mock_open):
with pytest.warns(UserWarning, match="Unable to find child cgroup"):
assert await Cgroup.get_cgroup_dir(12345) == Path("/sys/fs/cgroup/path")


@pytest.mark.self
class TestDisplayServer:
Expand Down
Loading