mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-26 15:49:58 +00:00
scan_log_for_errors: check that regex is correct (#9815)
## Problem I've noticed that we have 2 flaky tests which failed with error: ``` re.error: missing ), unterminated subpattern at position 21 ``` - `test_timeline_archival_chaos` — has been already fixed - `test_sharded_tad_interleaved_after_partial_success` — I didn't manage to find the incorrect regex [Internal link](https://neonprod.grafana.net/goto/yfmVHV7NR?orgId=1) ## Summary of changes - Wrap `re.match` in `try..except` block and print incorrect regex
This commit is contained in:
committed by
GitHub
parent
46beecacce
commit
899933e159
@@ -25,8 +25,14 @@ def scan_pageserver_log_for_errors(
|
|||||||
|
|
||||||
# It's an ERROR or WARN. Is it in the allow-list?
|
# It's an ERROR or WARN. Is it in the allow-list?
|
||||||
for a in allowed_errors:
|
for a in allowed_errors:
|
||||||
if re.match(a, line):
|
try:
|
||||||
break
|
if re.match(a, line):
|
||||||
|
break
|
||||||
|
# We can switch `re.error` with `re.PatternError` after 3.13
|
||||||
|
# https://docs.python.org/3/library/re.html#re.PatternError
|
||||||
|
except re.error:
|
||||||
|
print(f"Invalid regex: '{a}'", file=sys.stderr)
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
errors.append((lineno, line))
|
errors.append((lineno, line))
|
||||||
return errors
|
return errors
|
||||||
|
|||||||
@@ -495,8 +495,14 @@ def scan_log_for_errors(input: Iterable[str], allowed_errors: list[str]) -> list
|
|||||||
|
|
||||||
# It's an ERROR or WARN. Is it in the allow-list?
|
# It's an ERROR or WARN. Is it in the allow-list?
|
||||||
for a in allowed_errors:
|
for a in allowed_errors:
|
||||||
if re.match(a, line):
|
try:
|
||||||
break
|
if re.match(a, line):
|
||||||
|
break
|
||||||
|
# We can switch `re.error` with `re.PatternError` after 3.13
|
||||||
|
# https://docs.python.org/3/library/re.html#re.PatternError
|
||||||
|
except re.error:
|
||||||
|
log.error(f"Invalid regex: '{a}'")
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
errors.append((lineno, line))
|
errors.append((lineno, line))
|
||||||
return errors
|
return errors
|
||||||
|
|||||||
Reference in New Issue
Block a user