Skip to content

fix: Set manual parallelism since cgroups values are not used#76

Merged
lolgab merged 1 commit intomasterfrom
fix-limits
May 5, 2026
Merged

fix: Set manual parallelism since cgroups values are not used#76
lolgab merged 1 commit intomasterfrom
fix-limits

Conversation

@lolgab
Copy link
Copy Markdown

@lolgab lolgab commented Apr 30, 2026

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 32 which is the number of cores in the node. That creates a lot of contention.

@codacy-production
Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity

Metric Results
Complexity 0

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown

@codacy-production codacy-production Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Suggested change
"3",
sys.env.getOrElse("CPPCHECK_THREADS", "3"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We needed to set environment variables based on kubernetes from Worker. It's a mess.
It's much easier to maintain this by hand.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine with me then

@lolgab lolgab requested review from a team and lorandszakacs April 30, 2026 14:03
@lolgab lolgab merged commit e3cd824 into master May 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants