From 2dc537199a6be408e067149335d519bd1ab758a5 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Mar 23 2021 12:47:53 +0000 Subject: PR#2765: kojira: check repo.json before deleting Merges #2765 https://pagure.io/koji/pull-request/2765 Fixes: #1321 https://pagure.io/koji/issue/1321 [kojira] If tag is renamed, old repos will never be deleted --- diff --git a/util/kojira b/util/kojira index a616797..3c161dc 100755 --- a/util/kojira +++ b/util/kojira @@ -675,9 +675,18 @@ class RepoManager(object): self.rmtree(repodir) continue if rinfo['tag_name'] != tag: - self.logger.warning( - "Tag name mismatch (rename?): %s vs %s", tag, rinfo['tag_name']) - continue + try: + # possible rename of tag, repo.json should exist and contain tag id + repo_json = koji.load_json(os.path.join(repodir, 'repo.json')) + if rinfo['tag_id'] != repo_json['tag_id']: + self.logger.warning( + "Tag name/id mismatch: directory: %s, name: %s, id: %s", + tag, rinfo['tag_name'], repo_json['tag_id']) + continue + except Exception: + self.logger.warning( + "Tag name mismatch (rename?): %s vs %s", tag, rinfo['tag_name']) + continue if rinfo['state'] in (koji.REPO_DELETED, koji.REPO_PROBLEM): age = time.time() - max(rinfo['create_ts'], dir_ts) self.logger.debug("potential removal candidate: %s; age: %s" % (repodir, age))