fix(logfiles): report search failures instead of losing findings - #3585
Merged
Conversation
When the search retry on log rotation was exhausted, the raised FileNotFoundError aborted the whole log check. Findings that were already collected for other regexes, log files or searches were lost, expect_errors raised the raw exception instead of the assembled report, and the exception in the cluster manager teardown skipped the test stop cleanup. Report the failure as an error entry instead - per log file in the expected messages check and in the cluster logs search, and per search in the framework and supervisord log searches. The failed search is still reported loudly (as a check failure), it just cannot discard the other findings anymore. find_msgs_in_logs deliberately keeps propagating the failure - the caller needs the matching lines and an empty result would be misread as "no matches". Also modernize the expect_errors / expect_messages return annotations to tp.Generator.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the log-search utilities to report repeated log-rotation search failures as aggregated error entries (instead of raising and aborting the entire log check), ensuring previously collected findings aren’t lost. It also adds regression tests around this behavior and updates related documentation/type annotations.
Changes:
- Catch exhausted rotation-retry
FileNotFoundErrorin error-aggregating log searches and convert it into error entries (per log file / per search as appropriate). - Add framework tests that force permanent “rotated during search” behavior and assert failures are reported, not raised.
- Update
find_msgs_in_logsdocstring and modernizeexpect_errors/expect_messagesreturn type annotations.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| framework_tests/test_logfiles.py | Adds fixtures and tests asserting search failures are reported as error entries rather than aborting log checks. |
| cardano_node_tests/utils/logfiles.py | Implements failure-to-error aggregation for several log searches; updates docstrings and context-manager type annotations. |
Suppressed comments (1)
cardano_node_tests/utils/logfiles.py:1028
- Same typing issue as
expect_errors:tp.Generator[None]is invalid at runtime in this module (no postponed evaluation of annotations), so importinglogfiles.pywill fail. Use the fullGenerator[None, None, None]parameters (orIterator[None]).
def expect_messages(regex_pairs: list[tuple[str, str]]) -> tp.Generator[None]:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When the search retry on log rotation was exhausted, the raised FileNotFoundError aborted the whole log check. Findings that were already collected for other regexes, log files or searches were lost, expect_errors raised the raw exception instead of the assembled report, and the exception in the cluster manager teardown skipped the test stop cleanup.
Report the failure as an error entry instead - per log file in the expected messages check and in the cluster logs search, and per search in the framework and supervisord log searches. The failed search is still reported loudly (as a check failure), it just cannot discard the other findings anymore.
find_msgs_in_logs deliberately keeps propagating the failure - the caller needs the matching lines and an empty result would be misread as "no matches".
Also modernize the expect_errors / expect_messages return annotations to tp.Generator.