Refactor check_logs function in checker.py to improve subscription message detection. Changed from single match to iterating over all matches, allowing retrieval of the last subscription ID found in logs. Updated logging to reflect the last subscription message or indicate absence, enhancing clarity in log analysis.
This commit is contained in:
parent
625a8f71ae
commit
b93e5f890a
18
checker.py
18
checker.py
@ -123,14 +123,18 @@ def check_logs(log_handler):
|
|||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
raise RuntimeError(f"Error running docker logs: {e}") from e
|
raise RuntimeError(f"Error running docker logs: {e}") from e
|
||||||
|
|
||||||
subscription_pattern = r'Ignored subscription creation.*id=(\d+).*err=Subscription completed'
|
subscription_pattern = r'Ignored subscription creation.*id=(\d+)'
|
||||||
match = re.search(subscription_pattern, log_content)
|
matches = re.finditer(subscription_pattern, log_content)
|
||||||
if match:
|
last_id = None
|
||||||
subscription_id = match.group(1)
|
|
||||||
log_handler.info(f"Found subscription completion message, id: {subscription_id}")
|
|
||||||
return {"status": f"Subscription {subscription_id}"}
|
|
||||||
|
|
||||||
log_handler.info("No subscription completion message found")
|
for match in matches:
|
||||||
|
last_id = match.group(1)
|
||||||
|
|
||||||
|
if last_id:
|
||||||
|
log_handler.info(f"Found last subscription message, id: {last_id}")
|
||||||
|
return {"status": f"Subscription {last_id}"}
|
||||||
|
|
||||||
|
log_handler.info("No subscription message found")
|
||||||
return {"status": "Idle"}
|
return {"status": "Idle"}
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user