Add the ability to look up images which do not have a placement yet.
This commit is contained in:
parent
bf0e01fba5
commit
0a62f7f725
2 changed files with 19 additions and 1 deletions
|
@ -152,3 +152,6 @@ class DefaultConfig(object):
|
|||
}
|
||||
|
||||
DISTRIBUTED_STORAGE_PREFERENCE = ['local_us']
|
||||
|
||||
# Remove me when all imagestorage objects have a location
|
||||
DS_BACKFILL_LOCATION= 'local_us'
|
||||
|
|
|
@ -857,7 +857,22 @@ def get_repo_image(namespace_name, repository_name, image_id):
|
|||
Image.docker_image_id == image_id)))
|
||||
|
||||
if not location_list:
|
||||
return None
|
||||
# REMOVEME When all existing imagestorages have a placement
|
||||
try:
|
||||
logger.warning('Checking for image without placement')
|
||||
no_placement = (Image.select(Image, ImageStorage)
|
||||
.join(ImageStorage)
|
||||
.switch(Image)
|
||||
.join(Repository)
|
||||
.where(Repository.name == repository_name,
|
||||
Repository.namespace == namespace_name,
|
||||
Image.docker_image_id == image_id)
|
||||
.get())
|
||||
no_placement.storage.locations = {config.app_config['DS_BACKFILL_LOCATION']}
|
||||
return no_placement
|
||||
except Image.DoesNotExist:
|
||||
logger.warning('Unable to find image')
|
||||
return None
|
||||
|
||||
location_names = {location.location.name for location in location_list}
|
||||
|
||||
|
|
Reference in a new issue