Merge pull request #665 from coreos-inc/asyncgcforall
Enable async GC for all
This commit is contained in:
commit
ebab66a2b5
5 changed files with 2 additions and 22 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue