This commit is contained in:
Joseph Schorr 2014-10-17 16:22:22 -04:00
commit 01fdfa079f
2 changed files with 9 additions and 1 deletions

View file

@ -1,5 +1,5 @@
[loggers]
keys=root, gunicorn.error, gunicorn.access, application.profiler
keys=root, gunicorn.error, gunicorn.access, application.profiler, boto, werkzeug
[handlers]
keys=console

View file

@ -1394,6 +1394,13 @@ def garbage_collect_repository(namespace_name, repository_name):
logger.info('Cleaning up unreferenced images: %s', to_remove)
Image.delete().where(Image.id << list(to_remove)).execute()
if len(storage_id_whitelist) > 0:
garbage_collect_storage(storage_id_whitelist)
return len(to_remove)
def garbage_collect_storage(storage_id_whitelist):
# We are going to make the conscious decision to not delete image storage inside the transaction
# This may end up producing garbage in s3, trading off for higher availability in the database
def placements_query_to_paths_set(placements_query):
@ -1411,6 +1418,7 @@ def garbage_collect_repository(namespace_name, repository_name):
.group_by(ImageStorage)
.having((fn.Count(Image.id) == 0) & (fn.Count(DerivedImageStorage.id) == 0)))
logger.debug('Garbage collecting storage from candidates: %s', storage_id_whitelist)
with config.app_config['DB_TRANSACTION_FACTORY'](db):
# Find out which derived storages will be removed, and add them to the whitelist
orphaned_from_candidates = orphaned_storage_query(ImageStorage.select(), storage_id_whitelist)