Refactor the garbage collection code a tiny bit.
This commit is contained in:
parent
f5fff3657c
commit
2a89c2bb35
1 changed files with 4 additions and 2 deletions
|
@ -985,7 +985,9 @@ def garbage_collect_repository(namespace_name, repository_name):
|
|||
|
||||
referenced_anscestors = set()
|
||||
for tag in tag_query:
|
||||
ancestor_list = [int(img) for img in tag.image.ancestors.split('/')[1:-1]]
|
||||
# The anscestor list is in the format '/1/2/3/', extract just the ids
|
||||
anscestor_id_strings = tag.image.ancestors.split('/')[1:-1]
|
||||
ancestor_list = [int(img_id_str) for img_id_str in anscestor_id_strings]
|
||||
referenced_anscestors = referenced_anscestors.union(set(ancestor_list))
|
||||
referenced_anscestors.add(tag.image.id)
|
||||
|
||||
|
@ -999,8 +1001,8 @@ def garbage_collect_repository(namespace_name, repository_name):
|
|||
image_to_remove = all_images[image_id_to_remove]
|
||||
image_path = store.image_path(namespace_name, repository_name,
|
||||
image_to_remove.docker_image_id)
|
||||
logger.debug('Recursively deleting image path: %s' % image_path)
|
||||
image_to_remove.delete_instance()
|
||||
logger.debug('Deleting image storage: %s' % image_path)
|
||||
store.remove(image_path)
|
||||
|
||||
return len(to_remove)
|
||||
|
|
Reference in a new issue