This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/workers/diffsworker.py
2015-09-10 14:12:16 -04:00

37 lines
1.2 KiB
Python

import logging
from app import image_diff_queue
from data import model
from endpoints.v1.registry import process_image_changes
from workers.queueworker import QueueWorker
logger = logging.getLogger(__name__)
class DiffsWorker(QueueWorker):
def process_queue_item(self, job_details):
image_id = job_details['image_id']
repository = job_details['repository']
namespace = model.user.get_namespace_by_user_id(job_details['namespace_user_id'])
try:
process_image_changes(namespace, repository, image_id)
except model.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)
except IOError:
# This exception is unrecoverable, and the item should continue and be
# marked as complete.
msg = ("Data could not be retrieved for image %s under repo %s/%s" %
(image_id, namespace, repository))
logger.exception(msg)
return True
if __name__ == "__main__":
worker = DiffsWorker(image_diff_queue)
worker.start()