Skip to content

Commit

Permalink
helper docker: handle/log more connection errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke authored and maringuu committed Nov 7, 2023
1 parent 740e9c2 commit a33025b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/helperFunctions/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a33025b

Please sign in to comment.