#2765 kojira: check repo.json before deleting
Merged a year ago by tkopecek. Opened a year ago by tkopecek.
tkopecek/koji issue1321  into  master

file modified
+12 -3
@@ -676,9 +676,18 @@ 

                                  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))

maybe catching more generic Exceptions? 'tag_id' might not be in repo_json, and json.load() may fail with invalid format

rebased onto 6baa28d844eaf280950c436cce8fc9816f772b41

a year ago

rebased onto 1efac52

a year ago

At first I thought that we want to see other exception. On the other hand it shouldn't block kojira to do other tasks. so yes, updated to catch all exceptions.

Metadata Update from @tkopecek:
- Pull-request tagged with: no_qe

a year ago

Commit 2dc5371 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago
Metadata