-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Calculate linter.config.jobs in cgroupsv2 environments #10089
base: main
Are you sure you want to change the base?
Conversation
9ff146e
to
ff64dd8
Compare
This comment has been minimized.
This comment has been minimized.
ff64dd8
to
ab7b61b
Compare
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #10089 +/- ##
=======================================
Coverage 95.80% 95.80%
=======================================
Files 174 174
Lines 18962 18972 +10
=======================================
+ Hits 18166 18176 +10
Misses 796 796
|
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit ab7b61b |
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.
Awesome! Thanks for the PR. I just have some questions about structure and placement of the tests, but the code LGTM!
pylint/lint/run.py
Outdated
@@ -65,6 +65,18 @@ def _query_cpu() -> int | None: | |||
cpu_shares = int(file.read().rstrip()) | |||
# For AWS, gives correct value * 1024. | |||
avail_cpu = int(cpu_shares / 1024) | |||
elif Path("/sys/fs/cgroup/cpu.max").is_file(): |
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.
Shouldn't this take precedence over cpu.shares
? If the new file is present it should probably be preferred over the old one?
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.
I wouldn't expect them to co-exist so just went with a quick grouping around v1 vs v2 but it probably makes sense just in case.
I've pushed a new commit which prefers the v2 files and I think also makes the logic a bit clearer
tests/lint/test_run.py
Outdated
from pylint.testutils.utils import _test_cwd | ||
|
||
|
||
@pytest.mark.parametrize( |
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.
Why isn't this grouped with the other tests? I don't think we need a separate file as we don't follow the "file + test_file" structure
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.
I had a bit of confusion around using protected members in tests python. Figured it out and merged the tests back into the other file
ab7b61b
to
ad9f26c
Compare
Hey @DanielNoord! Thanks so much for the review. I've replied to your comments and pushed some fixes |
Type of Changes
Description
In containers running on cgroupv2 systems
_query_cpu
currently returnsNone
. This results insched_getaffinity
being used, which will normally return all installed CPUs of the host. This can result in crashes with the error:The changes here use the CPU quota in v2 systems.
max 100000
is the default value, and will continue to result in the hosts CPU count being used.cpu.weight
(the replacement of cpu shares from v1) could also be used, but as it's impact on CPU scheduling is relative to the rest of the cgroup hierarchy it isn't possible to get an accurate value on all systems where pylint may be run. Whereas this method is reliable on any container with a CPU quota