mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Do not erroneously mask exceptions
There was a catch-all `except` statement in `create_containers`: try: containers = do_create(count, params) except: self.pull_image() containers = do_create(count, params) This would mask a variety of errors that should be exposed, including API compatability errors (as in #1707) and common Python exceptions (KeyError, ValueError, etc) that could result from errors in the code. This change makes the `except` statement more specific, and only attempts to pull the image and start a container if the original create attempt failed due to a 404 error from the docker API.
This commit is contained in:
parent
6116e4cdab
commit
e031efd82c
1 changed files with 5 additions and 1 deletions
|
@ -401,6 +401,7 @@ from urlparse import urlparse
|
||||||
try:
|
try:
|
||||||
import docker.client
|
import docker.client
|
||||||
import docker.utils
|
import docker.utils
|
||||||
|
import docker.errors
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_DOCKER_PY = False
|
HAS_DOCKER_PY = False
|
||||||
|
@ -1347,7 +1348,10 @@ class DockerManager(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
containers = do_create(count, params)
|
containers = do_create(count, params)
|
||||||
except:
|
except docker.errors.APIError as e:
|
||||||
|
if e.response.status_code != 404:
|
||||||
|
raise
|
||||||
|
|
||||||
self.pull_image()
|
self.pull_image()
|
||||||
containers = do_create(count, params)
|
containers = do_create(count, params)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue