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