From 7a2fded072309f6d5f6093d87a57e987214d7dfc Mon Sep 17 00:00:00 2001 From: Dramelac Date: Mon, 9 Sep 2024 11:36:12 +0200 Subject: [PATCH] Handle another docker timeout error Signed-off-by: Dramelac --- exegol/utils/DockerUtils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/exegol/utils/DockerUtils.py b/exegol/utils/DockerUtils.py index 6f446d2c..6b932ab1 100644 --- a/exegol/utils/DockerUtils.py +++ b/exegol/utils/DockerUtils.py @@ -4,6 +4,7 @@ from typing import List, Optional, Union, cast import docker +import requests.exceptions from docker import DockerClient from docker.errors import APIError, DockerException, NotFound, ImageNotFound from docker.models.images import Image @@ -58,6 +59,8 @@ def __init__(self): logger.critical( "Unable to connect to docker (from env config). Is docker operational and accessible? on your machine? " "Exiting.") + except (ReadTimeout, requests.exceptions.ConnectionError): + logger.critical("Docker daemon seems busy, Exegol receives timeout response. Try again later.") self.__images: Optional[List[ExegolImage]] = None self.__containers: Optional[List[ExegolContainer]] = None @@ -556,9 +559,9 @@ def __remove_image(self, image_name: str) -> bool: try: self.__client.images.remove(image_name, force=False, noprune=False) return True - except ReadTimeout: + except (ReadTimeout, requests.exceptions.ConnectionError): logger.warning("The deletion of the image has timeout. Docker is still processing the removal, please wait.") - max_retry = 5 + max_retry = 10 wait_time = 5 for i in range(5): try: @@ -569,7 +572,7 @@ def __remove_image(self, image_name: str) -> bool: return True else: logger.debug(f"Unexpected error after timeout: {err}") - except ReadTimeout: + except (ReadTimeout, requests.exceptions.ConnectionError): wait_time = wait_time + wait_time * i logger.info(f"Docker timeout again ({i + 1}/{max_retry}). Next retry in {wait_time} seconds...") sleep(wait_time) # Wait x seconds before retry