Bug 1026793

Summary: check-sources chokes on broken yum repos
Product: OpenShift Container Platform Reporter: Luke Meyer <lmeyer>
Component: Cluster Version OperatorAssignee: John W. Lamb <jolamb>
Status: CLOSED ERRATA QA Contact: libra bugs <libra-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.0.0CC: libra-onpremise-devel, xiama
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-12-16 09:11:27 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Luke Meyer 2013-11-05 12:48:21 UTC
Description of problem:
New real-world pathological case here. If, in addition to your correct rhn/rhsm subscription, you have a yum repo enabled that's broken (in this case, points to a bad URL), check-sources crashes. Also, an install will fail (which was what brought this case to my attention).

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

Steps to Reproduce:
1. Try to install OSE to install from yum repos, but use URLs that don't work.
2. Subscribe to RHN/RHSM instead.
3. Run oo-admin-check-sources.py to sort it out.

Expected results:
Advice to fix or remove the broken yum repo(s).

Actual results:
# ./oo-admin-check-sources.py -r broker
Detected OpenShift Enterprise repository subscription managed by RHN Classic or RHN Satellite.
Detected installed OpenShift Enterprise version 1.2

Checking if yum-plugin-priorities is installed
Traceback (most recent call last):
  File "./oo-admin-check-sources.py", line 649, in <module>
    if not oacs.main():
  File "./oo-admin-check-sources.py", line 610, in main
    self.run_checks()
  File "./oo-admin-check-sources.py", line 586, in run_checks
    if not (self.verify_yum_plugin_priorities() or self.opts.report_all):
  File "./oo-admin-check-sources.py", line 267, in verify_yum_plugin_priorities
    if self.oscs.package_available('yum-plugin-priorities'):
  File "/root/openshift-extras/admin/check-sources/check_sources.py", line 305, in package_available
    return next((pkg for pkg in sg if pkg[0].name == name), None)
  File "/root/openshift-extras/admin/check-sources/check_sources.py", line 305, in <genexpr>
    return next((pkg for pkg in sg if pkg[0].name == name), None)
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 2566, in searchGenerator
    for sack in self.pkgSack.sacks.values():
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 887, in <lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 669, in _getSacks
    self.repos.populateSack(which=repos)
  File "/usr/lib/python2.6/site-packages/yum/repos.py", line 308, in populateSack
    sack.populate(repo, mdtype, callback, cacheonly)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 165, in populate
    if self._check_db_version(repo, mydbtype):
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 223, in _check_db_version
    return repo._check_db_version(mdtype)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1256, in _check_db_version
    repoXML = self.repoXML
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1455, in <lambda>
    repoXML = property(fget=lambda self: self._getRepoXML(),
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1451, in _getRepoXML
    raise Errors.RepoError, msg
yum.Errors.RepoError: Cannot retrieve repository metadata (repomd.xml) for repository: openshift_client. Please verify its path and try again

Comment 4 John W. Lamb 2013-11-05 16:47:21 UTC
Addressed in https://github.com/openshift/openshift-extras/pull/145

Comment 5 Ma xiaoqiang 2013-11-07 02:47:14 UTC
check it on new version
#rhnreg_ks --username=$user --password=$passwd --serverUrl=$url
#rhn-channel -c rhel-x86_64-server-6-ose-1.2-infrastructure -a
#rhn-channel -c rhel-x86_64-server-6-ose-2.0-infrastructure -a
# cat test.repo 
[openshift_infrastructure]
name=OpenShift Infrastructure
baseurl=http://buivm-devops.usersys.redhat.com/puddle/build/OpenShiftEnterpriseErrata/2.0/2013-11-05.1//RHOSE-INFRA-2.0/x86_64/os/
enabled=1
gpgcheck=0
priority=1
sslverify=false
#./oo-admin-check-sources.py  --role broker -p
Output:

Checking channel/repository priorities
Resolving repository/channel/subscription priority conflicts
To resolve conflicting repositories, update /etc/yum/pluginconf.d/rhnplugin.conf with the following changes:
    Set priority=10 in the [rhel-x86_64-server-6-ose-2.0-infrastructure] section
    Set priority=20 in the [rhel-x86_64-server-6] section
Traceback (most recent call last):
  File "./oo-admin-check-sources.py", line 671, in <module>
    if not oacs.main():
  File "./oo-admin-check-sources.py", line 621, in main
    self.run_checks()
  File "./oo-admin-check-sources.py", line 599, in run_checks
    if not (self.find_package_conflicts() or self.opts.report_all):
  File "./oo-admin-check-sources.py", line 494, in find_package_conflicts
    ose_pkgs = self.oscs.packages_for_repo(repoid, disable_priorities = True)
  File "/root/openshift-extras/admin/check-sources/check_sources.py", line 300, in packages_for_repo
    return self._yb_no_pri().pkgSack.returnPackages(repoid=repoid)
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 887, in <lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.6/site-packages/yum/__init__.py", line 669, in _getSacks
    self.repos.populateSack(which=repos)
  File "/usr/lib/python2.6/site-packages/yum/repos.py", line 308, in populateSack
    sack.populate(repo, mdtype, callback, cacheonly)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 165, in populate
    if self._check_db_version(repo, mydbtype):
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 223, in _check_db_version
    return repo._check_db_version(mdtype)
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1256, in _check_db_version
    repoXML = self.repoXML
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1455, in <lambda>
    repoXML = property(fget=lambda self: self._getRepoXML(),
  File "/usr/lib/python2.6/site-packages/yum/yumRepo.py", line 1451, in _getRepoXML
    raise Errors.RepoError, msg
yum.Errors.RepoError: Cannot retrieve repository metadata (repomd.xml) for repository: openshift_infrastructure. Please verify its path and try again

Comment 6 John W. Lamb 2013-11-07 14:15:56 UTC
Addressed again in https://github.com/openshift/openshift-extras/pull/157

Good catch!

Comment 7 Ma xiaoqiang 2013-11-08 01:03:32 UTC
check it on new version
#rhnreg_ks --username=$user --password=$passwd --serverUrl=$url
#rhn-channel -c rhel-x86_64-server-6-ose-1.2-infrastructure -a
#rhn-channel -c rhel-x86_64-server-6-ose-2.0-infrastructure -a
# cat test.repo 
[openshift_infrastructure]
name=OpenShift Infrastructure
baseurl=http://buivm-devops.usersys.redhat.com/puddle/build/OpenShiftEnterpriseErrata/2.0/2013-11-05.1//RHOSE-INFRA-2.0/x86_64/os/
enabled=1
gpgcheck=0
priority=1
sslverify=false
#./oo-admin-check-sources.py  --role broker -p
Output:

Detected OpenShift Enterprise repository subscription managed by RHN Classic or RHN Satellite.
Detected installed OpenShift Enterprise version 2.0

The following RHN Classic or RHN Satellite-managed OpenShift Enterprise repositories conflict with the detected or specified product version.
To prevent package conflicts, disable these repositories by making the following modifications to /etc/yum/pluginconf.d/rhnplugin.conf
    Set enabled=0 in the [rhel-x86_64-server-6-ose-1.2-infrastructure] section
The required OpenShift Enterprise repositories are missing:
    rhel-x86_64-server-6-rhscl-1
Please verify that an OpenShift Enterprise subscription is attached to this system using either RHN Classic or Red Hat Subscription Manager by following the instructions here: https://access.redhat.com/site/articles/522923
Checking if yum-plugin-priorities is installed
Checking channel/repository priorities
Resolving repository/channel/subscription priority conflicts
To resolve conflicting repositories, update /etc/yum/pluginconf.d/rhnplugin.conf with the following changes:
    Set priority=10 in the [rhel-x86_64-server-6-ose-2.0-infrastructure] section
    Set priority=20 in the [rhel-x86_64-server-6] section
An unrecoverable error prevents further checks from being run. Re-run this tool after the problem has been repaired:

Cannot retrieve repository metadata (repomd.xml) for repository: openshift_infrastructure. Please verify its path and try again