Update the diffs worker to not fail if the repository is removed before diffs are computed.

This commit is contained in:
yackob03 2013-11-13 14:41:20 -05:00
parent 5a2728c6a8
commit d7592fd133
2 changed files with 16 additions and 3 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]

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)