Check for errors before delegating to the cleanup function.

This commit is contained in:
yackob03 2014-02-05 19:59:26 -05:00
parent 67e0736fc6
commit fab699530c

View file

@ -54,7 +54,7 @@ class DockerfileBuildContext(object):
self._tag_name = tag_name self._tag_name = tag_name
self._push_token = push_token self._push_token = push_token
self._build_uuid = build_uuid self._build_uuid = build_uuid
self._cl = Client(timeout=1200) self._cl = Client(timeout=1200, version='1.7')
self._status = StatusWrapper(self._build_uuid) self._status = StatusWrapper(self._build_uuid)
dockerfile_path = os.path.join(self._build_dir, "Dockerfile") dockerfile_path = os.path.join(self._build_dir, "Dockerfile")
@ -100,7 +100,7 @@ class DockerfileBuildContext(object):
current_step = 0 current_step = 0
built_image = None built_image = None
for status in build_status: for status in build_status:
logger.debug('Status: %s', str(status)) logger.debug('Status: %s', str(status.encode('utf-8')))
build_logs.append_log_message(self._build_uuid, str(status)) build_logs.append_log_message(self._build_uuid, str(status))
step_increment = re.search(r'Step ([0-9]+) :', status) step_increment = re.search(r'Step ([0-9]+) :', status)
if step_increment: if step_increment:
@ -189,7 +189,11 @@ class DockerfileBuildContext(object):
repos = set() repos = set()
for image in self._cl.images(): for image in self._cl.images():
images_to_remove.add(image['Id']) images_to_remove.add(image['Id'])
repos.add(image['Repository'])
for tag in image['RepoTags']:
tag_repo = tag.split(':')[0]
if tag_repo != '<none>':
repos.add(tag_repo)
for repo in repos: for repo in repos:
repo_url = 'https://index.docker.io/v1/repositories/%s/images' % repo repo_url = 'https://index.docker.io/v1/repositories/%s/images' % repo
@ -275,9 +279,9 @@ class DockerfileBuildWorker(Worker):
repository_build.phase = 'building' repository_build.phase = 'building'
repository_build.save() repository_build.save()
try:
with DockerfileBuildContext(build_dir, tag_name, access_token, with DockerfileBuildContext(build_dir, tag_name, access_token,
repository_build.uuid) as build_ctxt: repository_build.uuid) as build_ctxt:
try:
built_image = build_ctxt.build() built_image = build_ctxt.build()
if not built_image: if not built_image: