Blame SOURCES/BZ-1445751-yum-debug-dump-improve-repo-failure-handling.patch

5b4f08
commit 61232e9f66cc64fffa8517678b6cf224d44b02ef
5b4f08
Author: Michal Domonkos <mdomonko@redhat.com>
5b4f08
Date:   Wed Jul 12 16:27:53 2017 +0200
5b4f08
5b4f08
    yum-debug-dump: improve repo failure handling. BZ 1445751
5b4f08
    
5b4f08
    Populate the repos prior to iterating over them in dump_repos().  This
5b4f08
    fixes the following bugs:
5b4f08
    
5b4f08
    1) KeyError when calling returnPackages() on a repo that was previously
5b4f08
       disabled by the pkgSack invocation in the same loop due to
5b4f08
       skip_if_unavailable=true (BZ 1445751)
5b4f08
    
5b4f08
    2) One broken repo with skip_if_unavailable=false would cause all other
5b4f08
       (even working) repos in the for loop to report the same error, thus
5b4f08
       making the %%%%REPOS section useless
5b4f08
5b4f08
diff --git a/yum-debug-dump.py b/yum-debug-dump.py
5b4f08
index 67d943f..01ca338 100755
5b4f08
--- a/yum-debug-dump.py
5b4f08
+++ b/yum-debug-dump.py
5b4f08
@@ -73,6 +73,26 @@ class YumDebugDump(yum.YumBase):
5b4f08
 
5b4f08
     def dump_repos(self):
5b4f08
         msg = "%%%%REPOS\n"
5b4f08
+
5b4f08
+        # Set up the sacks first, to capture and log any broken repos.  We
5b4f08
+        # cannot yet call returnPackages() from this loop as that would lead to
5b4f08
+        # a KeyError if some repo got disabled by pkgSack due to
5b4f08
+        # skip_if_unavailable=true in a previous iteration.
5b4f08
+        #
5b4f08
+        # A failure means remaining repos were not processed, so we have to
5b4f08
+        # retry the whole process ourselves by calling pkgSack again.  Since
5b4f08
+        # the worst case scenario is that all the repos are broken, we have to
5b4f08
+        # do this at least as many times as there are enabled repos.
5b4f08
+        for repo in sorted(self.repos.listEnabled()):
5b4f08
+            try:
5b4f08
+                self.pkgSack
5b4f08
+            except Errors.RepoError, e:
5b4f08
+                msg += "Error accessing repo %s: %s\n" % (e.repo, str(e))
5b4f08
+                self.repos.disableRepo(e.repo.id)
5b4f08
+            else:
5b4f08
+                break
5b4f08
+
5b4f08
+        # Dump the packages now
5b4f08
         for repo in sorted(self.repos.listEnabled()):
5b4f08
             try:
5b4f08
                 msg += '%%%s - %s\n' % (repo.id, repo.urls[0])