-
Notifications
You must be signed in to change notification settings - Fork 18
More log analyzer cleanup #155
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
Merged
openshift-merge-bot
merged 7 commits into
openshift-assisted:master
from
carbonin:cleanup
Nov 18, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c9aa6bf
Split signatures into individual files
carbonin d67b157
Remove extra 'cluster' key in metadata
carbonin b0bdd98
Add some helpers
carbonin 3b68bbc
Move the get_hostname helper out of LogAnalyzer
carbonin 77f701f
Reorganize test files
carbonin 80d8ec1
Fix auth test contamination
carbonin b0ccb8c
Refactor helper in slow image download and add some tests
carbonin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
assisted_service_mcp/src/utils/log_analyzer/signatures/api_expired_certificate_signature.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """ | ||
| ApiExpiredCertificateSignature for OpenShift Assisted Installer logs. | ||
| """ | ||
|
|
||
| import logging | ||
| import re | ||
| from typing import Optional | ||
|
|
||
| from assisted_service_mcp.src.utils.log_analyzer.log_analyzer import ( | ||
| LOG_BUNDLE_PATH, | ||
| ) | ||
|
|
||
| from .base import ErrorSignature, SignatureResult | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class ApiExpiredCertificateSignature(ErrorSignature): | ||
| """Detect expired or not yet valid certificate in kube-apiserver logs.""" | ||
|
|
||
| LOG_PATTERN = re.compile("x509: certificate has expired or is not yet valid.*") | ||
|
|
||
| def analyze(self, log_analyzer) -> Optional[SignatureResult]: | ||
| path = f"{LOG_BUNDLE_PATH}/bootstrap/containers/bootstrap-control-plane/kube-apiserver.log" | ||
| try: | ||
| logs = log_analyzer.logs_archive.get(path) | ||
| except FileNotFoundError: | ||
| return None | ||
| invalid_api_log_lines = self.LOG_PATTERN.findall(logs) | ||
| if invalid_api_log_lines: | ||
| content = invalid_api_log_lines[0] | ||
| if (num_lines := len(invalid_api_log_lines)) > 1: | ||
| content += f"\nadditional {num_lines - 1} similar error log lines found" | ||
| return self.create_result( | ||
| title="Expired Certificate", | ||
| content=content, | ||
| severity="error", | ||
| ) | ||
| return None |
39 changes: 39 additions & 0 deletions
39
assisted_service_mcp/src/utils/log_analyzer/signatures/api_invalid_certificate_signature.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| """ | ||
| ApiInvalidCertificateSignature for OpenShift Assisted Installer logs. | ||
| """ | ||
|
|
||
| import logging | ||
| import re | ||
| from typing import Optional | ||
|
|
||
| from .base import ErrorSignature, SignatureResult | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class ApiInvalidCertificateSignature(ErrorSignature): | ||
| """Detect invalid SAN values on certificate for AI API from controller logs.""" | ||
|
|
||
| LOG_PATTERN = re.compile( | ||
| 'time=".*" level=error msg=".*x509: certificate is valid.* not .*' | ||
| ) | ||
|
|
||
| def analyze(self, log_analyzer) -> Optional[SignatureResult]: | ||
| try: | ||
| controller_logs = log_analyzer.get_controller_logs() | ||
| except FileNotFoundError: | ||
| return None | ||
|
|
||
| invalid_api_log_lines = self.LOG_PATTERN.findall(controller_logs) | ||
| if invalid_api_log_lines: | ||
| shown = invalid_api_log_lines[:5] | ||
| more = len(invalid_api_log_lines) - len(shown) | ||
| content = "\n".join(shown) | ||
| if more > 0: | ||
| content += f"\nadditional {more} similar error log lines found" | ||
| return self.create_result( | ||
| title="Invalid SAN values on certificate for AI API", | ||
| content=content, | ||
| severity="error", | ||
| ) | ||
| return None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🧩 Analysis chain
Verify the regex pattern is complete.
The
LOG_PATTERNregex appears to be missing a closing quote or pattern marker. The pattern ends with'time=".*" level=error msg=".*x509: certificate is valid.* not .*'but typically x509 certificate error messages have more structure.Please verify this pattern matches the actual log format. Compare with similar patterns in the codebase (e.g.,
ApiExpiredCertificateSignature) to ensure consistency.🏁 Script executed:
Length of output: 148
🏁 Script executed:
Length of output: 0
🏁 Script executed:
Length of output: 183
🏁 Script executed:
Length of output: 1243
🏁 Script executed:
Length of output: 1307
The regex pattern is missing a closing quote for the message field.
The pattern
'time=".*" level=error msg=".*x509: certificate is valid.* not .*'opens the message field withmsg="but never closes it. While the Python string syntax is valid, the regex pattern itself is structurally incomplete. It should include a closing quote to properly match the log structure:Compare this to
api_expired_certificate_signature.pywhich uses a simpler pattern; the invalid certificate pattern requires closing the message field quote to properly validate against actual log output.🤖 Prompt for AI Agents