From a33025b4f725d63d5b393e5e6e283d2a1b967fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Stucke?= Date: Fri, 27 Oct 2023 09:29:42 +0200 Subject: [PATCH] helper docker: handle/log more connection errors --- src/helperFunctions/docker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/helperFunctions/docker.py b/src/helperFunctions/docker.py index a541fb5ba..144a70d9c 100644 --- a/src/helperFunctions/docker.py +++ b/src/helperFunctions/docker.py @@ -4,14 +4,14 @@ import docker from docker.errors import APIError, DockerException, ImageNotFound -from requests.exceptions import ReadTimeout +from requests.exceptions import ReadTimeout, RequestException def run_docker_container( image: str, logging_label: str = 'Docker', timeout: int = 300, combine_stderr_stdout: bool = False, **kwargs ) -> CompletedProcess: """ - This is a convinience function that runs a docker container and returns a + This is a convenience function that runs a docker container and returns a subprocess.CompletedProcess instance for the command ran in the container. All remaining keyword args are passed to `docker.containers.run`. @@ -51,6 +51,9 @@ def run_docker_container( except ReadTimeout: logging.warning(f'[{logging_label}]: timeout while processing') raise + except RequestException: + logging.warning(f'[{logging_label}]: connection error while processing') + raise except APIError: logging.warning(f'[{logging_label}]: encountered docker error while processing') raise