This commit is contained in:
Joseph Schorr 2013-11-13 17:47:59 -05:00
commit 8615e9236b
4 changed files with 29 additions and 4 deletions

View file

@ -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]
@ -910,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)

View file

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

View file

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

View file

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