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)