From 2b00ba41190ed771c84526c5c4b8dda47f676fff Mon Sep 17 00:00:00 2001 From: rthallisey Date: Mon, 24 Aug 2015 11:01:25 -0400 Subject: [PATCH] Fail faster when docker isn't running In order to make build.py more friendly, have it fail faster when the script is unable to connect to Docker because it's not running. Change-Id: I6d480e601ea2511df9396fcf4e89c06c06d4c21c Closes-Bug: #1488133 --- kolla/cmd/build.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/kolla/cmd/build.py b/kolla/cmd/build.py index b907673664..12ee128680 100755 --- a/kolla/cmd/build.py +++ b/kolla/cmd/build.py @@ -32,6 +32,7 @@ import time import docker import jinja2 +from requests.exceptions import ConnectionError logging.basicConfig() LOG = logging.getLogger(__name__) @@ -68,6 +69,13 @@ class WorkerThread(Thread): self.queue.task_done() except Queue.Empty: break + except ConnectionError as e: + LOG.error(e) + LOG.error('Make sure Docker is running and that you have ' + 'the correct privileges to run Docker (root)') + data['status'] = "connection_error" + self.queue.task_done() + break def process_source(self, source, dest_dir): if source.get('type') == 'url': @@ -89,7 +97,10 @@ class WorkerThread(Thread): image['status'] = "building" if image['parent'] is not None and \ - image['parent']['status'] in ['error', 'parent_error']: + image['parent']['status'] in ['error', 'parent_error', + 'connection_error']: + LOG.error('Parent image error\'d with message "%s"', + image['parent']['status']) image['status'] = "parent_error" return