Bug 524454

Summary: yum repolist accesses all repos
Product: [Fedora] Fedora Reporter: Mads Kiilerich <mads>
Component: yumAssignee: Seth Vidal <skvidal>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: rawhideCC: ffesti, james.antill, maxamillion, pmatilai, tim.lauridsen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-09-25 03:56:47 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mads Kiilerich 2009-09-20 12:51:00 UTC
Description of problem:

yum repolist accesses all repos. That is a problem one of the repos for some reason (which isn't relevant here) doesn't work and I want a list of all my repos so that I can see which I can to disable and enable.

[root@localhost ~]# yum -y repolist
Not loading "blacklist" plugin, as it is disabled
Loading "fastestmirror" plugin
Loading "merge-conf" plugin
Loading "presto" plugin
Loading "refresh-packagekit" plugin
Loading "remove-with-leaves" plugin
Not loading "whiteout" plugin, as it is disabled
Running "config" handler for "merge-conf" plugin
Running "config" handler for "presto" plugin
Running "config" handler for "remove-with-leaves" plugin
Config time: 0.390
Running "init" handler for "fastestmirror" plugin
Yum Version: 3.2.24
COMMAND: yum -y repolist 
Installroot: /
Running "postreposetup" handler for "fastestmirror" plugin
Loading mirror speeds from cached hostfile
^C^C^C^C^C^C^C

I expect repolist to be a meta-ish command which doesn't _use_ repo configs but only reports them - at least when -v isn't specified.


Version-Release number of selected component (if applicable):

yum-metadata-parser-1.1.2-14.fc12.i686
yum-plugin-fastestmirror-1.1.23-3.fc12.noarch
yum-plugin-merge-conf-1.1.23-3.fc12.noarch
yum-presto-0.6.1-1.fc12.noarch
yum-3.2.24-4.fc12.noarch
yum-NetworkManager-dispatcher-1.1.23-3.fc12.noarch
yum-plugin-remove-with-leaves-1.1.23-3.fc12.noarch
yum-utils-1.1.23-3.fc12.noarch

Comment 1 James Antill 2009-09-21 06:06:32 UTC
Proposed fix for upstream:

    Catch and ignore any repo. errors, and allow cache only (BZ 524454)

diff --git a/yumcommands.py b/yumcommands.py
index bd73d0c..3d88ee4 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -778,13 +778,17 @@ class RepoListCommand(YumCommand):
             arg = 'enabled'
         extcmds = map(lambda x: x.lower(), extcmds)
 
-        # Setup so len(repo.sack) is correct
-        base.repos.populateSack()
+        verbose = base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
+        try:
+            # Setup so len(repo.sack) is correct
+            base.repos.populateSack()
+        except yum.Errors.RepoError:
+            if verbose:
+                raise
 
         repos = base.repos.repos.values()
         repos.sort()
         enabled_repos = base.repos.listEnabled()
-        verbose = base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
         if arg == 'all':
             ehibeg = base.term.FG_COLOR['green'] + base.term.MODE['bold']
             dhibeg = base.term.FG_COLOR['red']

...this means that "yum repolist -C all" will now always work (without hitting the network).

Comment 2 Mads Kiilerich 2009-09-21 21:08:16 UTC
I am not familiar with the yum codebase, but at a first glance it seems like this patch "just" would make it acceptable that contacting the repos failed unless verbose. In my specific case where yum hang while trying to contact a repo that isn't good enough.

And AFAICS a plain repolist without verbose doesn't use anything from the server anyway, so why contact them at all?

This patch to yum-3.2.24-4.fc12.noarch seems to give the behaviour I would like:

--- /usr/share/yum-cli/yumcommands.py-	2009-09-21 23:02:01.000000000 +0200
+++ /usr/share/yum-cli/yumcommands.py	2009-09-21 23:02:48.000000000 +0200
@@ -778,13 +778,14 @@
             arg = 'enabled'
         extcmds = map(lambda x: x.lower(), extcmds)
 
-        # Setup so len(repo.sack) is correct
-        base.repos.populateSack()
+        verbose = base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
+        if verbose:
+            # Setup so len(repo.sack) is correct
+            base.repos.populateSack()
 
         repos = base.repos.repos.values()
         repos.sort()
         enabled_repos = base.repos.listEnabled()
-        verbose = base.verbose_logger.isEnabledFor(logginglevels.DEBUG_3)
         if arg == 'all':
             ehibeg = base.term.FG_COLOR['green'] + base.term.MODE['bold']
             dhibeg = base.term.FG_COLOR['red']

Comment 3 James Antill 2009-09-22 02:38:38 UTC
 As I said in my last comment:

this means that "yum repolist -C all" will now always work (without hitting
the network).

...feel free to use an alias or whatever if you always want that behaviour.

 Upstream commit is now in as:

http://yum.baseurl.org/gitweb?p=yum.git;a=commitdiff;h=2ffe59eb3e441f3fce3038d1c19079cc5c59eb74

...but I think new F11 packages should be in updates-testing "soon", if you don't want to apply it by hand it.

Comment 4 Mads Kiilerich 2009-09-22 08:55:21 UTC
Yes, I saw that -C worked without hitting the network. That is fine and definitely an improvement. It did however not cross my mind to try to use -C, so it wouldn't have helped _me_ in that situation.

My point is that there is _no_ need for repolist without -C and without -v to hit the network. For that reason I think it would be nice if it didn't do that.

I assume that you got my point but disagree and say that the rule is that yum without -C hits the network and yum with -C doesn't and you don't want execptions. Ok. You write the code and you decide ;-)

Comment 5 James Antill 2009-09-25 03:56:47 UTC
> My point is that there is _no_ need for repolist without -C and without -v to
> hit the network.

 It hits the network so it can get the package counts, I guess there are cases where this might not be that useful but there are some where it's very useful.

> say that the rule is that yum without -C hits the network

 The rule is only that yum without -C _can_ hit the network, but we try not to if there's no reason to (for instance "yum remove" doesn't). At the same time we don't try to optimize for broken repos. ... so you'd have to have a pretty good argument for removing the package counts.

 Anyway, a yum with the fix is in rawhide now.

Comment 6 Mads Kiilerich 2009-09-27 01:44:25 UTC
You are right. Package count is a reason to always try to connect. I hadn't noticed the package counts in the output.

Comment 7 Fedora Update System 2009-09-30 01:39:42 UTC
yum-3.2.24-2.fc11 has been pushed to the Fedora 11 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 8 Fedora Update System 2009-10-19 16:46:06 UTC
yum-3.2.24-2.fc10 has been submitted as an update for Fedora 10.
http://admin.fedoraproject.org/updates/yum-3.2.24-2.fc10

Comment 9 Fedora Update System 2009-11-04 12:07:03 UTC
yum-3.2.24-2.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.