-
Notifications
You must be signed in to change notification settings - Fork 25
Change rlimit nproc resource limit to apply to the autotester process #587
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
Conversation
…t-nproc # Conflicts: # server/autotest_server/tests/test_rlimit.py
|
@david-yz-liu Requesting review. |
david-yz-liu
left a comment
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.
@ch-iv great work. I left a few inline comments; also please update the changelog.
|
|
||
|
|
||
| class MockTester(Tester): | ||
| def __init__( |
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.
Please omit the initializer entirely (as it isn't doing anything other than forwarding the arguments)
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.
Could you please clarify how you want me to do this, because I've tried a few things, but none of them worked.
I've tried:
class MockTester(Tester):
def run(self) -> None:
passIn the above code I get TypeError: Can't instantiate abstract class MockTester without an implementation for abstract method '__init__'.
I've also tried:
class MockTester(Tester):
def __init__(
self,
specs: TestSpecs,
test_class: Type[Test] | None = Test,
resource_settings: list[tuple[int, tuple[int, int]]] | None = None,
) -> None:
pass
def run(self) -> None:
passWhich raises AttributeError: 'MockTester' object has no attribute 'resource_settings'.
Then I asked chat, which suggested to do:
class MockTester(Tester):
__init__ = Tester.__init__
def run(self) -> None:
passBut I still get TypeError: Can't instantiate abstract class MockTester without an implementation for abstract method '__init__'
I think this is because the Tester.__init__ method is defined as abstract, so it has to be implemented in the MockTester class. However, Tester.__init__ also does some setup, so all classes inhering from Tester must either call Tester.__init__ or reimplement that setup logic.
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.
@ch-iv you're right about this, I had missed the @abstractmethod decorator on the initializer. I'm good to leave this as-is!
david-yz-liu
left a comment
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.
Nice work, @ch-iv!
|
|
||
|
|
||
| class MockTester(Tester): | ||
| def __init__( |
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.
@ch-iv you're right about this, I had missed the @abstractmethod decorator on the initializer. I'm good to leave this as-is!
This PR changes the resource limit on the number of extant processes (
resource.RLIMIT_NPROC) to apply to each individual worker rather than to the entire docker user.Refactors the
set_rlimits_before_testfunction to remove the nproc adjustment, because it became obsolete due to earlier changes.Adds a small change to how the rlimit value is validated. Previously the soft limit would be set to
min(soft, hard), however that produced an incorrect result whenhard = resource.RLIMIT_INFINITY(-1).Adds tests for
get_resource_settings,get_setrlimit_lines, andvalidate_rlimit.