From 08bacf72c8505e0ca7a0226397724a9b7c9e5dbd Mon Sep 17 00:00:00 2001 From: Tobias Persson Date: Thu, 25 Apr 2024 14:41:07 +0200 Subject: [PATCH] Make sure we do all in our power to release an environment --- .../utilities/external_provider.py | 7 ++++++- src/iut_provider/utilities/external_provider.py | 7 ++++++- src/log_area_provider/utilities/external_provider.py | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/execution_space_provider/utilities/external_provider.py b/src/execution_space_provider/utilities/external_provider.py index 25e0d5f..0e891d9 100644 --- a/src/execution_space_provider/utilities/external_provider.py +++ b/src/execution_space_provider/utilities/external_provider.py @@ -25,7 +25,7 @@ from etos_lib.lib.http import Http from jsontas.jsontas import JsonTas from packageurl import PackageURL -from requests.exceptions import HTTPError +from requests.exceptions import HTTPError, ConnectionError as RequestsConnectionError from urllib3.util import Retry from environment_provider.lib.encrypt import encrypt @@ -132,6 +132,11 @@ def checkin(self, execution_space: ExecutionSpace) -> None: raise ExecutionSpaceCheckinFailed( f"Unable to check in {execution_spaces} " f"({response.get('error')})" ) + except RequestsConnectionError as error: + if "connection refused" in str(error).lower(): + self.logger.error("Error connecting to %r: %r", host, error) + continue + raise except ConnectionError: self.logger.error("Error connecting to %r", host) continue diff --git a/src/iut_provider/utilities/external_provider.py b/src/iut_provider/utilities/external_provider.py index 122a5d3..b285442 100644 --- a/src/iut_provider/utilities/external_provider.py +++ b/src/iut_provider/utilities/external_provider.py @@ -25,7 +25,7 @@ from etos_lib.lib.http import Http from jsontas.jsontas import JsonTas from packageurl import PackageURL -from requests.exceptions import HTTPError +from requests.exceptions import HTTPError, ConnectionError as RequestsConnectionError from urllib3.util import Retry from ..exceptions import IutCheckinFailed, IutCheckoutFailed, IutNotAvailable @@ -122,6 +122,11 @@ def checkin(self, iut: Iut) -> None: response = response.json() if response.get("error") is not None: raise IutCheckinFailed(f"Unable to check in {iuts} ({response.get('error')})") + except RequestsConnectionError as error: + if "connection refused" in str(error).lower(): + self.logger.error("Error connecting to %r: %r", host, error) + continue + raise except ConnectionError: self.logger.error("Error connecting to %r", host) continue diff --git a/src/log_area_provider/utilities/external_provider.py b/src/log_area_provider/utilities/external_provider.py index 4d8db82..415ad15 100644 --- a/src/log_area_provider/utilities/external_provider.py +++ b/src/log_area_provider/utilities/external_provider.py @@ -25,7 +25,7 @@ from etos_lib.lib.http import Http from jsontas.jsontas import JsonTas from packageurl import PackageURL -from requests.exceptions import HTTPError +from requests.exceptions import HTTPError, ConnectionError as RequestsConnectionError from urllib3.util import Retry from ..exceptions import LogAreaCheckinFailed, LogAreaCheckoutFailed, LogAreaNotAvailable @@ -126,6 +126,11 @@ def checkin(self, log_area: LogArea) -> None: raise LogAreaCheckinFailed( f"Unable to check in {log_areas} ({response.get('error')})" ) + except RequestsConnectionError as error: + if "connection refused" in str(error).lower(): + self.logger.error("Error connecting to %r: %r", host, error) + continue + raise except ConnectionError: self.logger.error("Error connecting to %r", host) continue