You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

48 lines
2.0 KiB

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