Switch the checksums to use the registry computed value, remove all assumptions of namespaced paths for legacy storage, fix an upload race condition in the registry code.

This commit is contained in:
Jake Moshenko 2014-06-11 15:37:45 -04:00
parent 246a216f80
commit 78c5aec5b9
11 changed files with 112 additions and 264 deletions

View file

@ -1011,14 +1011,6 @@ def find_create_or_link_image(docker_image_id, repository, username,
return new_image
def set_image_checksum(docker_image_id, repository, checksum):
fetched = Image.get(Image.docker_image_id == docker_image_id,
Image.repository == repository)
fetched.checksum = checksum
fetched.save()
return fetched
def set_image_size(docker_image_id, namespace_name, repository_name,
image_size):
try:
@ -1122,15 +1114,9 @@ def garbage_collect_repository(namespace_name, repository_name):
for image_id_to_remove in to_remove:
image_to_remove = all_images[image_id_to_remove]
if image_to_remove.storage and image_to_remove.storage.id:
logger.debug('Adding image storage to the gc list: %s',
image_to_remove.storage.uuid)
uuids_to_check_for_gc.add(image_to_remove.storage.uuid)
else:
image_path = config.store.image_path(namespace_name, repository_name,
image_to_remove.docker_image_id, None)
logger.debug('Deleting image storage: %s', image_path)
config.store.remove(image_path)
logger.debug('Adding image storage to the gc list: %s',
image_to_remove.storage.uuid)
uuids_to_check_for_gc.add(image_to_remove.storage.uuid)
image_to_remove.delete_instance()
@ -1145,8 +1131,7 @@ def garbage_collect_repository(namespace_name, repository_name):
for storage in storage_to_remove:
logger.debug('Garbage collecting image storage: %s', storage.uuid)
storage.delete_instance()
image_path = config.store.image_path(namespace_name, repository_name,
image_to_remove.docker_image_id, storage.uuid)
image_path = config.store.image_path(storage.uuid)
config.store.remove(image_path)
return len(to_remove)