#2765 kojira: check repo.json before deleting
Merged 3 years ago by tkopecek. Opened 3 years 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

3 years ago

rebased onto 1efac52

3 years 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

3 years ago

Commit 2dc5371 fixes this pull-request

Pull-Request has been merged by tkopecek

3 years ago
Metadata