From a8504a2ba70a97ad57fdcf49e9d5088ff34798c8 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 24 Feb 2017 16:37:38 -0500 Subject: [PATCH 1/2] Fail if expecting to run in Docker but not available. --- cwltool/job.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cwltool/job.py b/cwltool/job.py index 6e841f64d..8e9a513c1 100644 --- a/cwltool/job.py +++ b/cwltool/job.py @@ -137,13 +137,16 @@ def run(self, dry_run=False, pull_image=True, rm_container=True, env = None # type: Union[MutableMapping[Text, Text], MutableMapping[str, str]] if docker_req and kwargs.get("use_container") is not False: env = os.environ - img_id = docker.get_from_requirements(docker_req, docker_is_req, pull_image) + img_id = docker.get_from_requirements(docker_req, True, pull_image) elif kwargs.get("default_container", None) is not None: env = os.environ img_id = kwargs.get("default_container") - if docker_is_req and img_id is None: - raise WorkflowException("Docker is required for running this tool.") + if docker_req and img_id is None: + if docker_is_req: + raise WorkflowException("Docker is required to run this tool.") + else: + raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker.") if img_id: runtime = ["docker", "run", "-i"] From c45eb6b18b4383c8f05473e78fc589e2c3fb5ce7 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Mon, 27 Feb 2017 15:23:29 -0500 Subject: [PATCH 2/2] Try to improve error handling when Docker is not available to run job in container. --- cwltool/job.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/cwltool/job.py b/cwltool/job.py index 8e9a513c1..378d76d30 100644 --- a/cwltool/job.py +++ b/cwltool/job.py @@ -135,18 +135,22 @@ def run(self, dry_run=False, pull_image=True, rm_container=True, img_id = None env = None # type: Union[MutableMapping[Text, Text], MutableMapping[str, str]] - if docker_req and kwargs.get("use_container") is not False: - env = os.environ - img_id = docker.get_from_requirements(docker_req, True, pull_image) - elif kwargs.get("default_container", None) is not None: - env = os.environ - img_id = kwargs.get("default_container") - - if docker_req and img_id is None: + try: + if docker_req and kwargs.get("use_container") is not False: + env = os.environ + img_id = docker.get_from_requirements(docker_req, True, pull_image) + elif kwargs.get("default_container", None) is not None: + env = os.environ + img_id = kwargs.get("default_container") + + if docker_req and img_id is None and kwargs.get("use_container"): + raise Exception("Docker image not available") + except Exception as e: + _logger.debug("Docker error", exc_info=True) if docker_is_req: - raise WorkflowException("Docker is required to run this tool.") + raise WorkflowException("Docker is required to run this tool: %s" % e) else: - raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker.") + raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker: %s" % e) if img_id: runtime = ["docker", "run", "-i"]