-
Notifications
You must be signed in to change notification settings - Fork 117
feat(error-detection): add multiple pattern support #2325
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
base: main
Are you sure you want to change the base?
feat(error-detection): add multiple pattern support #2325
Conversation
|
/gemini review |
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.
Code Review
This pull request introduces a valuable enhancement by adding support for multiple error detection patterns at both the global and repository levels. The implementation is well-structured, with corresponding updates to the CRD, configuration parsing, and documentation. The code is clean and the new tests cover the added functionality. I've found one logic issue where the documented behavior for disabling error detection at the repository level is not correctly implemented. My review includes a suggestion to fix this.
| if repoErrorDetection.Patterns != nil { | ||
| patterns = repoErrorDetection.Patterns | ||
| } |
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.
There's a logic issue here that contradicts the feature's documentation. According to the CRD documentation, providing an empty patterns array (patterns: []) should effectively disable error detection for the repository. However, the current implementation appends the global patterns even when the repository-specific patterns list is empty, causing it to fall back to global patterns instead of disabling detection. This could lead to unexpected behavior for users who want to opt-out of error detection for a specific repository.
To align with the documentation, you should check if repoErrorDetection.Patterns is an empty slice and, if so, stop further pattern processing for this repository.
| if repoErrorDetection.Patterns != nil { | |
| patterns = repoErrorDetection.Patterns | |
| } | |
| if repoErrorDetection.Patterns != nil { | |
| // As per documentation, an empty list of patterns disables error detection for the repo. | |
| if len(repoErrorDetection.Patterns) == 0 { | |
| return annotations | |
| } | |
| patterns = repoErrorDetection.Patterns | |
| } |
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.
Have made it more explicit in the docs that empty pattern list WOULD NOT disable error detection for the repo.
feefb68 to
f922a79
Compare
f922a79 to
a0046de
Compare
| // parseErrorDetectionPatterns parses the error-detection-simple-regexp from ConfigMap | ||
| // and populates ErrorDetectionSimpleRegexp as []string. It supports: | ||
| // 1. Single string pattern (backward compatible) | ||
| // 2. JSON array format: ["pattern1", "pattern2"] | ||
| // 3. Newline-separated patterns (YAML multi-line). | ||
| func parseErrorDetectionPatterns(setting *Settings, config map[string]string) error { |
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.
Would love some inputs on this. This approach came to my mind to ensure backward compatibility while allowing multiple patterns as input.
| {{< hint info >}} | ||
| **Global Override:** The global `error-detection-from-container-logs` setting | ||
| must be enabled (default: `true`) for error detection to work. If disabled | ||
| globally, repository-level settings cannot override it. | ||
| {{< /hint >}} |
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.
Have kept a global override so admins could disable error detection at an org level (for whatever (?) reason).
a0046de to
905496c
Compare
905496c to
49b7a7c
Compare
Add support for configuring multiple error detection regex patterns at both global (ConfigMap) and repository (CR) levels. This allows users to match different error formats from various linters and tools in a single pipeline. Global Configuration (ConfigMap): - Changed error-detection-simple-regexp to support arrays - Supports 3 formats: single pattern (backward compatible), multi-line YAML, and JSON array Repository CR: - Added ErrorDetectionSettings with patterns array and max_number_of_lines - Patterns are additive with global patterns - Per-repository max_number_of_lines override Jira: https://issues.redhat.com/browse/SRVKP-7237 Signed-off-by: Akshay Pant <[email protected]> Assisted-by: Cursor <[email protected]>
49b7a7c to
b4099d4
Compare
📝 Description of the Change
Add support for configuring multiple error detection regex patterns at both global (ConfigMap) and repository (CR) levels. This allows users to match different error formats from various linters and tools in a single pipeline.
Global Configuration (ConfigMap):
Repository CR:
👨🏻 Linked Jira
Jira: https://issues.redhat.com/browse/SRVKP-7237
🔗 Linked GitHub Issue
N/A
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Gemini [email protected]
Co-authored-by: ChatGPT [email protected]
Co-authored-by: Claude [email protected]
Co-authored-by: Cursor [email protected]
Co-authored-by: Copilot [email protected]
**💡You can use the script
./hack/add-llm-coauthor.shto automatically addthese co-author trailers to your commits.
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.