-
-
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 18973 18992 +19
=======================================
+ Hits 18177 18196 +19
Misses 796 796
|
This comment has been minimized.
This comment has been minimized.
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 |
This comment has been minimized.
This comment has been minimized.
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.
Hey @DominicLavery thank you for the PR ! would you mind adding a new changelog please ? (By adding a file here: https://github.com/pylint-dev/pylint/tree/main/doc/whatsnew/fragments)
2240807
to
c22610e
Compare
Thanks @Pierre-Sassoulas! Absolutely :) I've pushed that change |
Ah I suspect now that the v2 checks are happening first, I need to add a mock along the lines of
to |
This comment has been minimized.
This comment has been minimized.
c22610e
to
b7c849a
Compare
This comment has been minimized.
This comment has been minimized.
I moved some code around to minimize the diff and make more apparent that the existing code was not modified. This should help with the coverage job being unhappy. |
(But better test coverage would be appreciated if you feel inclined to test the existing code better than it was originally π ) |
π€ According to the primer, this change has no effect on the checked open source code. π€π This comment was generated for commit 972f45e |
Sorry @DominicLavery, life got very busy all of a sudden and I didn't have time to finish this review. If @Pierre-Sassoulas approves the PR I'm happy as well! Thanks for your contribution! :) |
No worries @DanielNoord! @Pierre-Sassoulas I've added some extra tests and created shared mock set ups to dedupe a bit. Hope this helps :) |
Thank you @DominicLavery appreciated. It seems some tests are failing now, not sure about why in the pylint job, it's a strange fail. Let me know if I need to approve the pipeline again so it runs. Or we might merge the previous version so you can run pipelines automatically on the refactor. |
I think both failures are explained by #10114. |
Thanks jacobtylerwalls! I've subscribed to the issues and will rebase when I see them closed |
Pardon my pushing to your branch: I just want to test out the proposed fix in the astroid repo and see how far that gets us. |
This comment was marked as resolved.
This comment was marked as resolved.
c7eca12
to
d1eb6a6
Compare
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 quotaCloses #10103