From ef9cb3757d1d7b9341f2f926ded620747a4ca946 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Tue, 21 Feb 2017 10:59:27 -0500 Subject: [PATCH] Check for missing repository on GC call Fixes https://sentry.io/coreos/backend-production/issues/192273882/ --- data/model/repository.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/data/model/repository.py b/data/model/repository.py index 6709b3f09..46de62bf7 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -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