Update the audit script for geographic distribution.
This commit is contained in:
parent
6047f3759f
commit
b47742b011
1 changed files with 11 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from data.database import Image, ImageStorage, Repository
|
from data.database import Image, ImageStorage, Repository, configure
|
||||||
from data import model
|
from data import model
|
||||||
from app import app, storage as store
|
from app import app, storage as store
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@ from app import app, storage as store
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logging.basicConfig(level=logging.DEBUG)
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
|
configure(app.config)
|
||||||
|
|
||||||
# Turn off debug logging for boto
|
# Turn off debug logging for boto
|
||||||
logging.getLogger('boto').setLevel(logging.CRITICAL)
|
logging.getLogger('boto').setLevel(logging.CRITICAL)
|
||||||
|
|
||||||
|
@ -17,7 +19,8 @@ query = (Image
|
||||||
.select(Image, ImageStorage, Repository)
|
.select(Image, ImageStorage, Repository)
|
||||||
.join(ImageStorage)
|
.join(ImageStorage)
|
||||||
.switch(Image)
|
.switch(Image)
|
||||||
.join(Repository))
|
.join(Repository)
|
||||||
|
.where(Repository.name == 'userportal', Repository.namespace == 'crsinc'))
|
||||||
|
|
||||||
bad_count = 0
|
bad_count = 0
|
||||||
good_count = 0
|
good_count = 0
|
||||||
|
@ -59,9 +62,11 @@ def all_ancestors_exist(ancestors):
|
||||||
cant_fix = []
|
cant_fix = []
|
||||||
for img in query:
|
for img in query:
|
||||||
try:
|
try:
|
||||||
|
with_locations = model.get_repo_image(img.repository.namespace, img.repository.name,
|
||||||
|
img.docker_image_id)
|
||||||
ancestry_storage = store.image_ancestry_path(img.storage.uuid)
|
ancestry_storage = store.image_ancestry_path(img.storage.uuid)
|
||||||
if store.exists(ancestry_storage):
|
if store.exists(with_locations.storage.locations, ancestry_storage):
|
||||||
full_ancestry = json.loads(store.get_content(ancestry_storage))[1:]
|
full_ancestry = json.loads(store.get_content(with_locations.storage.locations, ancestry_storage))[1:]
|
||||||
full_ancestry.reverse()
|
full_ancestry.reverse()
|
||||||
|
|
||||||
ancestor_dbids = [int(anc_id)
|
ancestor_dbids = [int(anc_id)
|
||||||
|
@ -84,6 +89,8 @@ for img in query:
|
||||||
bad_count += 1
|
bad_count += 1
|
||||||
else:
|
else:
|
||||||
good_count += 1
|
good_count += 1
|
||||||
|
else:
|
||||||
|
bad_count += 1
|
||||||
|
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
cant_fix.append(img)
|
cant_fix.append(img)
|
||||||
|
|
Reference in a new issue