From 6047f3759fa0563c8c8249b9152798fea501e65d Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Tue, 24 Jun 2014 17:01:23 -0400 Subject: [PATCH] Remove the placement fallback since the DB has been fully backfilled. --- config.py | 3 --- data/model/legacy.py | 17 +---------------- tools/backfillplacements.py | 26 -------------------------- 3 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 tools/backfillplacements.py diff --git a/config.py b/config.py index 3f00d8b6f..79866aaf2 100644 --- a/config.py +++ b/config.py @@ -152,6 +152,3 @@ class DefaultConfig(object): } DISTRIBUTED_STORAGE_PREFERENCE = ['local_us'] - - # Remove me when all imagestorage objects have a location - DS_BACKFILL_LOCATION = 'local_us' diff --git a/data/model/legacy.py b/data/model/legacy.py index f2c1b9e61..0bbca5c9e 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -857,22 +857,7 @@ def get_repo_image(namespace_name, repository_name, image_id): Image.docker_image_id == image_id))) if not location_list: - # 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 + return None location_names = {location.location.name for location in location_list} diff --git a/tools/backfillplacements.py b/tools/backfillplacements.py deleted file mode 100644 index b849ca86b..000000000 --- a/tools/backfillplacements.py +++ /dev/null @@ -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)