Remove the placement fallback since the DB has been fully backfilled.
This commit is contained in:
parent
da12b940a9
commit
6047f3759f
3 changed files with 1 additions and 45 deletions
|
@ -152,6 +152,3 @@ class DefaultConfig(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
DISTRIBUTED_STORAGE_PREFERENCE = ['local_us']
|
DISTRIBUTED_STORAGE_PREFERENCE = ['local_us']
|
||||||
|
|
||||||
# Remove me when all imagestorage objects have a location
|
|
||||||
DS_BACKFILL_LOCATION = 'local_us'
|
|
||||||
|
|
|
@ -857,22 +857,7 @@ def get_repo_image(namespace_name, repository_name, image_id):
|
||||||
Image.docker_image_id == image_id)))
|
Image.docker_image_id == image_id)))
|
||||||
|
|
||||||
if not location_list:
|
if not location_list:
|
||||||
# REMOVEME When all existing imagestorages have a placement
|
return None
|
||||||
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}
|
location_names = {location.location.name for location in location_list}
|
||||||
|
|
||||||
|
|
|
@ -1,26 +0,0 @@
|
||||||
import logging
|
|
||||||
|
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
|
||||||
|
|
||||||
from data.database import ImageStorage, ImageStoragePlacement, ImageStorageLocation
|
|
||||||
from peewee import *
|
|
||||||
|
|
||||||
from app import app
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
GROUP_SIZE = 1000
|
|
||||||
|
|
||||||
storage_needing_placements = (ImageStorage
|
|
||||||
.select()
|
|
||||||
.join(ImageStoragePlacement, JOIN_LEFT_OUTER)
|
|
||||||
.group_by(ImageStorage)
|
|
||||||
.having(fn.Count(ImageStoragePlacement.id) == 0))
|
|
||||||
|
|
||||||
default_location = ImageStorageLocation.get(name=app.config['DS_BACKFILL_LOCATION'])
|
|
||||||
|
|
||||||
while storage_needing_placements.count() > 0:
|
|
||||||
logger.debug('Starting group of %s', GROUP_SIZE)
|
|
||||||
for needs_placement in list(storage_needing_placements.limit(GROUP_SIZE)):
|
|
||||||
logger.debug('Adding placement: %s', needs_placement.id)
|
|
||||||
ImageStoragePlacement.create(storage=needs_placement, location=default_location)
|
|
Reference in a new issue