fix: Set manual parallelism since cgroups values are not used#76
fix: Set manual parallelism since cgroups values are not used#76
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
The PR addresses an issue where dynamic processor detection failed to respect Kubernetes cgroup limits by hardcoding the parallelism level to 3. Codacy analysis indicates that the code is up to standards and no new quality issues were introduced. However, the change introduces a direct coupling between the application logic and specific infrastructure resource limits. Furthermore, there are no unit tests included to verify the correct generation of the command-line arguments. It is recommended to implement an environment variable for flexibility and add a test case to ensure the -j flag is correctly formatted.
About this PR
- No unit tests were updated or added to verify the change in the command-line argument list structure or the hardcoded value.
- The solution relies on manual synchronization of constants between repositories (e.g., matching the CPU limits in codacy-tools), which is prone to human error and difficult to track over time.
Test suggestions
- Verify that the generated command list contains the '-j' flag and the value '3' as separate entries.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that the generated command list contains the '-j' flag and the value '3' as separate entries.
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| "-j", | ||
| // Keep in sync with CPU limits in codacy-tools | ||
| // https://github.com/codacy/codacy-tools/blob/61104fe51fd0c3fa54af76a3ec1a2ff409950320/persistence-plugins/src/main/scala/com/codacy/tools/persistenceplugins/docker/cpp/cppcheck/Cppcheck.scala#L23 | ||
| "3", |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Hardcoding the parallelism count to 3 makes the tool less flexible to changes in the execution environment. Consider using an environment variable to allow this value to be tuned without code changes.
| "3", | |
| sys.env.getOrElse("CPPCHECK_THREADS", "3"), |
There was a problem hiding this comment.
Can we try this version with reading env variables? Or is this what you referred to in the PR description?
tried reading automatically the values set by Kubernetes but I couldn't make it work
There was a problem hiding this comment.
We needed to set environment variables based on kubernetes from Worker. It's a mess.
It's much easier to maintain this by hand.
I tried reading automatically the values set by Kubernetes but I couldn't make it work.
I'm going to add a companion comment in codacy-tools to make sure we keep the values in sync.
Nowadays we are passing
32which is the number of cores in the node. That creates a lot of contention.