Merge pull request #2555 from coreos-inc/fix-backfill-script

Fill backfill script for recent changes
This commit is contained in:
josephschorr 2017-04-19 16:52:29 -04:00 committed by GitHub
commit 25b9cd4421

View file

@ -2,7 +2,8 @@ import logging
import features
from app import storage, image_replication_queue
from data.database import Image, ImageStorage, Repository, User
from data.database import (Image, ImageStorage, Repository, User, ImageStoragePlacement,
ImageStorageLocation)
from data import model
from util.registry.replication import queue_storage_replication
@ -19,10 +20,17 @@ def backfill_replication():
if image.storage.uuid in encountered:
continue
namespace = image.repository.namespace_user.username
namespace = image.repository.namespace_user
locations = model.user.get_region_locations(namespace)
locations_required = locations | set(storage.default_locations)
locations_missing = locations_required - set(image.storage.locations)
query = (ImageStoragePlacement
.select(ImageStoragePlacement, ImageStorageLocation)
.where(ImageStoragePlacement.storage == image.storage)
.join(ImageStorageLocation))
existing_locations = set([p.location.name for p in query])
locations_missing = locations_required - existing_locations
if locations_missing:
print "Enqueueing image storage %s to be replicated" % (image.storage.uuid)
encountered.add(image.storage.uuid)