From 393f49ba1b88e1c0a509fa57fc67e6964d2b9088 Mon Sep 17 00:00:00 2001 From: sandstromviktor Date: Mon, 22 Apr 2024 14:58:19 +0200 Subject: [PATCH] catching ApiException --- serve_event_listener/event_listener.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/serve_event_listener/event_listener.py b/serve_event_listener/event_listener.py index a5b4a98..2b91866 100644 --- a/serve_event_listener/event_listener.py +++ b/serve_event_listener/event_listener.py @@ -7,6 +7,7 @@ import requests import urllib3 from kubernetes import client, config, watch +from kubernetes.client.exceptions import ApiException from status_data import StatusData from status_queue import StatusQueue @@ -128,6 +129,12 @@ def listen(self) -> None: time.sleep(retry_delay) retries += 1 + except ApiException as e: + logger.error(f"ApiException occurred: {e!r}") + logger.info(f"Retrying in {retry_delay} seconds...") + time.sleep(retry_delay) + retries += 1 + except Exception as e: logger.error("Event listener exception occurred:") logger.exception(e)