Skip to content

Commit

Permalink
fixes Prow log filtering error (#80)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsebastiani authored Nov 9, 2023
1 parent f9a1075 commit de7d344
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/krkn_lib/utils/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ def filter_log_line(
:return: the log line if matches the criteria above otherwise None
"""
try:
if len(log_filter_patterns) == 0:
logging.error(
"no log filter patterns has been defined in config file,"
"unable to filter logfile. Skipping"
)
return None
log_date = None
for pattern in log_filter_patterns:
if pattern.groups != 1:
Expand All @@ -172,13 +178,15 @@ def filter_log_line(
log_date = parser.parse(pattern.search(log_line).groups()[0])
break

is_in_interval = check_date_in_localized_interval(
start_timestamp,
end_timestamp,
int(log_date.timestamp()),
remote_timezone,
local_timezone,
)
is_in_interval = False
if log_date is not None and isinstance(log_date, datetime.datetime):
is_in_interval = check_date_in_localized_interval(
start_timestamp,
end_timestamp,
int(log_date.timestamp()),
remote_timezone,
local_timezone,
)

if is_in_interval:
return log_line
Expand Down

0 comments on commit de7d344

Please sign in to comment.