diff --git a/conf/logging.conf b/conf/logging.conf index 6dadc997b..2b3308bbf 100644 --- a/conf/logging.conf +++ b/conf/logging.conf @@ -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 diff --git a/data/model/legacy.py b/data/model/legacy.py index 791ad3944..12f344681 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -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)