From ebca0abc82c5a0253a2ec665d88c51e6df2dd8d6 Mon Sep 17 00:00:00 2001 From: Jake Moshenko Date: Tue, 6 May 2014 15:13:43 -0400 Subject: [PATCH] Update the ancestry audit to actually check that the ancestors match the ones they should. --- tools/auditancestry.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/auditancestry.py b/tools/auditancestry.py index 8e32da820..ecf24330a 100644 --- a/tools/auditancestry.py +++ b/tools/auditancestry.py @@ -97,6 +97,16 @@ def resolve_or_create(repo, docker_image_id, new_ancestry): raise RuntimeError() +def all_ancestors_exist(ancestors): + if not ancestors: + return True + + found_count = len(list(Image + .select() + .where(Image.id << ancestors))) + return found_count == len(ancestors) + + cant_fix = [] for img in query: try: @@ -112,7 +122,7 @@ for img in query: ancestor_dbids = [int(anc_id) for anc_id in img.ancestors.split('/')[1:-1]] - if len(full_ancestry) != len(ancestor_dbids): + if len(full_ancestry) != len(ancestor_dbids) or not all_ancestors_exist(ancestor_dbids): logger.error('Image has incomplete ancestry: %s, %s, %s, %s' % (img.id, img.docker_image_id, full_ancestry, ancestor_dbids))