Skip to content

Commit

Permalink
Handle another docker timeout error
Browse files Browse the repository at this point in the history
Signed-off-by: Dramelac <[email protected]>
  • Loading branch information
Dramelac committed Sep 9, 2024
1 parent d63dceb commit 7a2fded
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions exegol/utils/DockerUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit 7a2fded

Please sign in to comment.