]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-build.git/commitdiff
prune-quay.py: fix deletion of busy ref names (master etc.) 1734/head
authorDan Mick <dmick@redhat.com>
Tue, 2 Feb 2021 08:19:44 +0000 (08:19 +0000)
committerDan Mick <dmick@redhat.com>
Wed, 3 Feb 2021 09:45:31 +0000 (01:45 -0800)
We must only delete the ref name if it refers to the same image
as the ref-shortsha1-el form of the name; if it's been pushed as a
new build of ref from a new sha1, it's no longer the image we
need to delete.  Verify the ref tag points to the same image as the
ref-shortsha1-el tag.

Signed-off-by: Dan Mick <dmick@redhat.com>
quay-pruner/build/prune-quay.py

index 7d0787f541c41c14ecfc944c65829a4f1abc41a1..6703691354d4f05e5dc25b7193b84ff8e74fbe88 100755 (executable)
@@ -237,7 +237,20 @@ def main():
             print('Marking %s for deletion' % name)
         tags_to_delete.add(name)
         if ref:
-            tags_to_delete.add(ref)
+            # the ref tag may already have been overwritten by a new
+            # build of the same ref, but a different sha1. Delete it only
+            # if it refers to the same image_id as the full tag.
+            names_of_same_image = \
+                [t['name'] for t in quaytags
+                 if t['image_id'] == tag['image_id']]
+            if ref in names_of_same_image:
+                if args.verbose:
+                    print('Marking %s for deletion' % name)
+                    tags_to_delete.add(name)
+            else:
+                if args.verbose:
+                    print('Skipping %s: not in %s' %
+                          (name, names_of_same_image))
         if short_sha1:
             if args.verbose:
                 print('Marking %s for 2nd-pass deletion' % short_sha1)