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
This commit is contained in:
rthallisey 2015-08-24 11:01:25 -04:00
parent eb05118a3f
commit 2b00ba4119

View File

@ -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