From 5941f3937c172c95d9ab382f66cff5dce503a973 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 19 Oct 2015 14:22:41 -0400 Subject: [PATCH] Enable async GC for all Fixes #569 --- data/model/repository.py | 14 +------------- endpoints/api/tag.py | 3 --- endpoints/v1/index.py | 3 --- endpoints/v1/tag.py | 2 -- workers/gcworker.py | 2 +- 5 files changed, 2 insertions(+), 22 deletions(-) diff --git a/data/model/repository.py b/data/model/repository.py index 3d1a0cfe3..be94ccac2 100644 --- a/data/model/repository.py +++ b/data/model/repository.py @@ -62,11 +62,7 @@ def purge_repository(namespace_name, repository_name): fetched.delete_instance(recursive=True, delete_nullable=False) -def find_repository_with_garbage(filter_list=None): - # TODO(jschorr): Remove the filter once we have turned the experiment on for everyone. - if filter_list is not None and not filter_list: - return None - +def find_repository_with_garbage(): epoch_timestamp = get_epoch_timestamp() try: @@ -80,9 +76,6 @@ def find_repository_with_garbage(filter_list=None): .limit(500) .alias('candidates')) - if filter_list: - candidates = candidates.where(Namespace.username << filter_list) - found = (RepositoryTag .select(candidates.c.repository_id) .from_(candidates) @@ -100,11 +93,6 @@ def find_repository_with_garbage(filter_list=None): def garbage_collect_repository(namespace_name, repository_name): - # If the namespace is the async experiment, don't perform garbage collection here. - # TODO(jschorr): Remove this check once we have turned the experiment on for everyone. - if namespace_name in config.app_config.get('EXP_ASYNC_GARBAGE_COLLECTION', []): - return - repo = get_repository(namespace_name, repository_name) if repo is not None: garbage_collect_repo(repo) diff --git a/endpoints/api/tag.py b/endpoints/api/tag.py index 986893c5d..b657e5827 100644 --- a/endpoints/api/tag.py +++ b/endpoints/api/tag.py @@ -105,7 +105,6 @@ class RepositoryTag(RepositoryParamResource): pass model.tag.create_or_update_tag(namespace, repository, tag, image_id) - model.repository.garbage_collect_repository(namespace, repository) username = get_authenticated_user().username log_action('move_tag' if original_image_id else 'create_tag', namespace, @@ -120,7 +119,6 @@ class RepositoryTag(RepositoryParamResource): def delete(self, namespace, repository, tag): """ Delete the specified repository tag. """ model.tag.delete_tag(namespace, repository, tag) - model.repository.garbage_collect_repository(namespace, repository) username = get_authenticated_user().username log_action('delete_tag', namespace, @@ -193,7 +191,6 @@ class RevertTag(RepositoryParamResource): # Revert the tag back to the previous image. image_id = request.get_json()['image'] model.tag.revert_tag(tag_image.repository, tag, image_id) - model.repository.garbage_collect_repository(namespace, repository) # Log the reversion. username = get_authenticated_user().username diff --git a/endpoints/v1/index.py b/endpoints/v1/index.py index 96e119444..b17a42f50 100644 --- a/endpoints/v1/index.py +++ b/endpoints/v1/index.py @@ -236,9 +236,6 @@ def update_images(namespace, repository): # Make sure the repo actually exists. abort(404, message='Unknown repository', issue='unknown-repo') - logger.debug('GCing repository') - model.repository.garbage_collect_repository(namespace, repository) - # Generate a job for each notification that has been added to this repo logger.debug('Adding notifications for repository') diff --git a/endpoints/v1/tag.py b/endpoints/v1/tag.py index 70a23e089..094c905df 100644 --- a/endpoints/v1/tag.py +++ b/endpoints/v1/tag.py @@ -82,8 +82,6 @@ def delete_tag(namespace, repository, tag): if permission.can(): model.tag.delete_tag(namespace, repository, tag) - model.repository.garbage_collect_repository(namespace, repository) - return make_response('Deleted', 200) abort(403) diff --git a/workers/gcworker.py b/workers/gcworker.py index acbcd0a6c..559095ebc 100644 --- a/workers/gcworker.py +++ b/workers/gcworker.py @@ -15,7 +15,7 @@ class GarbageCollectionWorker(Worker): def _garbage_collection_repos(self): """ Performs garbage collection on repositories. """ with UseThenDisconnect(app.config): - repository = find_repository_with_garbage(app.config.get('EXP_ASYNC_GARBAGE_COLLECTION', [])) + repository = find_repository_with_garbage() if repository is None: logger.debug('No repository with garbage found') return