Check for missing repository on GC call

Fixes https://sentry.io/coreos/backend-production/issues/192273882/
This commit is contained in:
Joseph Schorr 2017-02-21 10:59:27 -05:00
parent 89b7c13da5
commit ef9cb3757d

View file

@ -54,7 +54,10 @@ def purge_repository(namespace_name, repository_name):
not need to be checked or responded to.
"""
repo = _basequery.get_existing_repository(namespace_name, repository_name)
try:
repo = _basequery.get_existing_repository(namespace_name, repository_name)
except Repository.DoesNotExist:
return False
# Delete all tags to allow gc to reclaim storage
previously_referenced = tag.purge_all_tags(repo)
@ -74,7 +77,11 @@ def purge_repository(namespace_name, repository_name):
return False
# Delete the rest of the repository metadata
fetched = _basequery.get_existing_repository(namespace_name, repository_name)
try:
fetched = _basequery.get_existing_repository(namespace_name, repository_name)
except Repository.DoesNotExist:
return False
fetched.delete_instance(recursive=True, delete_nullable=False)
return True