From 5a2728c6a854dd4038cb20700bee666f69b48324 Mon Sep 17 00:00:00 2001 From: yackob03 Date: Mon, 11 Nov 2013 20:00:01 -0500 Subject: [PATCH 1/3] Fix the curl usage to get a single tag. --- endpoints/tags.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/endpoints/tags.py b/endpoints/tags.py index 41a103975..7267d7b7e 100644 --- a/endpoints/tags.py +++ b/endpoints/tags.py @@ -39,7 +39,9 @@ def get_tag(namespace, repository, tag): if permission.can() or model.repository_is_public(namespace, repository): tag_image = model.get_tag_image(namespace, repository, tag) - response = make_response(tag_image.docker_image_id, 200) + resp = make_response('"%s"' % tag_image.docker_image_id) + resp.headers['Content-Type'] = 'application/json' + return resp abort(403) From d7592fd1332d518292958a374a60dfa574a8ba7a Mon Sep 17 00:00:00 2001 From: yackob03 Date: Wed, 13 Nov 2013 14:41:20 -0500 Subject: [PATCH 2/3] Update the diffs worker to not fail if the repository is removed before diffs are computed. --- data/model.py | 4 +++- workers/diffsworker.py | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/data/model.py b/data/model.py index cae167acf..87568d169 100644 --- a/data/model.py +++ b/data/model.py @@ -662,7 +662,9 @@ def get_image_by_id(namespace_name, repository_name, docker_image_id): Image.docker_image_id == docker_image_id)) if not fetched: - raise DataModelException('Unable to find image for tag with repo.') + raise DataModelException('Unable to find image \'%s\' for repo \'%s/%s\'' % + (docker_image_id, namespace_name, + repository_name)) return fetched[0] diff --git a/workers/diffsworker.py b/workers/diffsworker.py index ce81b96f0..cacf48856 100644 --- a/workers/diffsworker.py +++ b/workers/diffsworker.py @@ -8,6 +8,7 @@ from apscheduler.scheduler import Scheduler from data.queue import image_diff_queue from data.database import db as db_connection +from data.model import DataModelException from endpoints.registry import process_image_changes @@ -29,8 +30,18 @@ def process_work_items(): logger.debug('Queue gave us some work: %s' % item.body) request = json.loads(item.body) - process_image_changes(request['namespace'], request['repository'], - request['image_id']) + try: + image_id = request['image_id'] + namespace = request['namespace'] + repository = request['repository'] + + process_image_changes(namespace, repository, image_id) + except DataModelException: + # This exception is unrecoverable, and the item should continue and be + # marked as complete. + msg = ('Image does not exist in database \'%s\' for repo \'%s/\'%s\'' % + (image_id, namespace, repository)) + logger.warning(msg) image_diff_queue.complete(item) From 0f3d942b5e82d619bdc71fa14a58893b71bf1ec1 Mon Sep 17 00:00:00 2001 From: yackob03 Date: Wed, 13 Nov 2013 17:29:26 -0500 Subject: [PATCH 3/3] Re-add the missing method for getting repository builds. Add more logging to try to see why some builds are not getting removed from the queue. --- data/model.py | 8 ++++++++ workers/dockerfilebuild.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/data/model.py b/data/model.py index 87568d169..cfbb9340c 100644 --- a/data/model.py +++ b/data/model.py @@ -912,6 +912,14 @@ def load_token_data(code): raise InvalidTokenException('Invalid delegate token code: %s' % code) +def get_repository_build(request_dbid): + try: + return RepositoryBuild.get(RepositoryBuild.id == request_dbid) + except RepositoryBuild.DoesNotExist: + msg = 'Unable to locate a build by id: %s' % request_dbid + raise InvalidRepositoryBuildException(msg) + + def list_repository_builds(namespace_name, repository_name, include_inactive=True): joined = RepositoryBuild.select().join(Repository) diff --git a/workers/dockerfilebuild.py b/workers/dockerfilebuild.py index b78cb8b0c..a03342ea0 100644 --- a/workers/dockerfilebuild.py +++ b/workers/dockerfilebuild.py @@ -219,9 +219,11 @@ def process_work_items(pool): local_item = item def complete_callback(completed): if completed: + logger.debug('Queue item completed successfully, will be removed.') dockerfile_build_queue.complete(local_item) else: # We have a retryable error, add the job back to the queue + logger.debug('Queue item incomplete, will be retryed.') dockerfile_build_queue.incomplete(local_item) return complete_callback