catch docker api exceptions
This commit is contained in:
parent
e51773b46b
commit
424f1c0e74
|
@ -7,6 +7,7 @@ LABEL maintainer="Robert Kaussow <mail@geeklabor.de>" \
|
||||||
org.label-schema.schema-version="1.0"
|
org.label-schema.schema-version="1.0"
|
||||||
|
|
||||||
ENV PY_COLORS=1
|
ENV PY_COLORS=1
|
||||||
|
ENV TZ=UTC
|
||||||
|
|
||||||
ADD dist/docker_tidy-*.whl /
|
ADD dist/docker_tidy-*.whl /
|
||||||
|
|
||||||
|
|
|
@ -295,7 +295,10 @@ class GarbageCollector:
|
||||||
|
|
||||||
def _get_docker_client(self):
|
def _get_docker_client(self):
|
||||||
config = self.config.config
|
config = self.config.config
|
||||||
return docker.APIClient(version="auto", timeout=config["http_timeout"])
|
try:
|
||||||
|
return docker.APIClient(version="auto", timeout=config["http_timeout"])
|
||||||
|
except docker.errors.DockerException as e:
|
||||||
|
self.log.sysexit_with_message("Can't create docker client\n{}".format(e))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Garbage collector main method."""
|
"""Garbage collector main method."""
|
||||||
|
|
|
@ -447,3 +447,7 @@ def test_build_exclude_set_empty(gc):
|
||||||
gc.config.config["gc"]["exclude_images"] = []
|
gc.config.config["gc"]["exclude_images"] = []
|
||||||
exclude_set = gc._build_exclude_set()
|
exclude_set = gc._build_exclude_set()
|
||||||
assert exclude_set == set()
|
assert exclude_set == set()
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_docker_client(gc, mocker):
|
||||||
|
assert isinstance(gc.docker, docker.APIClient)
|
||||||
|
|
Loading…
Reference in New Issue