View Issue Details

IDProjectCategoryView StatusLast Update
0001014channel: elrepo/el7yum-plugin-elrepopublic2020-06-22 16:00
Reporterbtlogy Assigned Topperry  
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Summary0001014: yum-plugin-elrepo 7.5.2 breaks yum upgrade with elrepo disabled
DescriptionWe're regularly running a yum upgrade command on CentOS 7.8.2003 while disabling some extra repos like elrepo.
And this is now failing with yum-plugin-repo 7.5.2 and still works when we downgrade to 7.5.1:

---
# yum upgrade --disablerepo="elrepo"
Loaded plugins: elrepo, fastestmirror
Loading mirror speeds from cached hostfile
Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 375, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 184, in main
    result, resultmsgs = base.doCommands()
  File "/usr/share/yum-cli/cli.py", line 585, in doCommands
    return self.yum_cli_commands[self.basecmd].doCommand(self, self.basecmd, self.extcmds)
  File "/usr/share/yum-cli/yumcommands.py", line 1811, in doCommand
    ret = base.updatePkgs(extcmds, update_to=(basecmd == 'upgrade-to'))
  File "/usr/share/yum-cli/cli.py", line 1069, in updatePkgs
    self.update()
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 5149, in update
    updates = self.up.getUpdatesTuples()
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1094, in <lambda>
    up = property(fget=lambda self: self._getUpdates(),
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 838, in _getUpdates
    self._up = rpmUtils.updates.Updates(self.rpmdb.simplePkgList(), self.pkgSack.simplePkgList())
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1075, in <lambda>
    pkgSack = property(fget=lambda self: self._getSacks(),
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 792, in _getSacks
    self.plugins.run('exclude')
  File "/usr/lib/python2.7/site-packages/yum/plugins.py", line 188, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/lib/yum-plugins/elrepo.py", line 85, in exclude_hook
    if count:
NameError: global name 'count' is not defined
---

Commenting the 2 last line of /usr/lib/yum-plugins/elrepo.py is a workaround.

I'm trying to move this 'global count' definition around the file, but I've found the way to make it work.
TagsNo tags attached.
Attached Files
elrepo.py (2,972 bytes)   
#!/usr/bin/python
#
# yum-plugin-elrepo - a yum plugin to remove kmod packages from the
#                     yum transaction set which require kernels which
#                     are not yet available.
#
# Copyright (C) 2018-2020 Philip J Perry <phil@elrepo.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#

from yum.plugins import TYPE_CORE
import fnmatch

requires_api_version = '2.6'
plugin_type = (TYPE_CORE,)

def init_hook(conduit):
    global kernels
    kernels = []

def exclude_hook(conduit):

    global count
    count = 0

    # get installed kernels
    instpkgs = conduit.getRpmDB().returnPackages()
    for instpkg in instpkgs:
        if instpkg.name == "kernel":
            kernels.append('kernel-modules >= ' + instpkg.version + '-' + instpkg.release + '.' + instpkg.arch)
            conduit.info(4, '[elrepo]: found installed kernel: %s' % instpkg)

    # get available kernels
    pkgs = conduit.getPackages()
    for pkg in pkgs:
        if pkg.name == "kernel":
            kernels.append('kernel-modules >= ' + pkg.version + '-' + pkg.release + '.' + pkg.arch)
            conduit.info(4, '[elrepo]: found kernel: %s' % pkg)

    if not kernels:
        conduit.info(2, '[elrepo]: ERROR, no kernels found')
        return

    def find_matches(kmod, requires, matchfor=None):

        global count

        # Skip installed packages
        if kmod.repo.id == "installed":
            return

        # Skip non-elrepo packages
        if not (kmod.release).endswith(".elrepo"):
            return

        for req in requires:
            for kernel in kernels:
                if fnmatch.fnmatch(kernel, req):
                    return
        # else no matching kernel, excluding package
        conduit.info(3, '[elrepo]: excluding package: %s' % kmod)
        conduit.delPackage(kmod)
        count += 1

        # if kmod-nvidia, handle matching nvidia-x11-drv packages
        if (kmod.name).startswith("kmod-nvidia"):
            for pkg in pkgs:
                if (pkg.name).startswith("nvidia-x11-drv"):
                    if kmod.version == pkg.version and kmod.release == pkg.release:
                        conduit.info(3, '[elrepo]: excluding package: %s' % pkg)
                        conduit.delPackage(pkg)
                        count += 1

    conduit._base.searchPackageProvides(['kernel-modules >= *', ], callback=find_matches, callback_has_matchfor=True)
    if count:
        conduit.info(2, '[elrepo]: %d kmod packages excluded due to dependency errors' % count)
elrepo.py (2,972 bytes)   
Reported upstream

Activities

pperry

2020-06-22 10:47

administrator   ~0006981

Hi,

I don't doubt your report, but I am unable to reproduce this on RHEL7?

Please can you provide the steps to reproduce.

I have tried disabling elrepo in /etc/yum/pluginconf.d/elrepo.conf and disabling on the yum command line:

yum update --disablerepo=elrepo\*

and am unable to trigger the error.

pperry

2020-06-22 10:51

administrator   ~0006982

OK, I think I see the cause. I'll work on a fix and report back here.

Thanks for the report.

pperry

2020-06-22 11:31

administrator   ~0006983

Last edited: 2020-06-22 11:32

Please can you try the uploaded elrepo.py attached to this bug

Please copy the attached file to /usr/lib/yum-plugins/elrepo.py and run:

python -O -m compileall /usr/lib/yum-plugins/elrepo.py

Then please test your usual use cases and see if this fixes the issue for you.

Thanks

btlogy

2020-06-22 12:55

reporter   ~0006984

This uploaded version of elrepo.py seems to fix my problem indeed.
Thanks for your help.

pperry

2020-06-22 15:41

administrator   ~0006985

Great, thank you for the feedback.

I will update the package now and release the fixed package shortly.

pperry

2020-06-22 15:59

administrator   ~0006986

Updated packages released:

yum-plugin-elrepo-7.5.3-1.el7.elrepo.src.rpm
yum-plugin-elrepo-7.5.3-1.el7.elrepo.noarch.rpm

Marking this bug resolved. Please feel free to post back if you find any further issues.

Thanks for the report and feedback.

Issue History

Date Modified Username Field Change
2020-06-22 03:31 btlogy New Issue
2020-06-22 03:31 btlogy Status new => assigned
2020-06-22 03:31 btlogy Assigned To => pperry
2020-06-22 10:47 pperry Note Added: 0006981
2020-06-22 10:51 pperry Note Added: 0006982
2020-06-22 11:29 pperry File Added: elrepo.py
2020-06-22 11:31 pperry Note Added: 0006983
2020-06-22 11:31 pperry Status assigned => feedback
2020-06-22 11:31 pperry Additional Information Updated
2020-06-22 11:32 pperry Note Edited: 0006983
2020-06-22 12:55 btlogy Note Added: 0006984
2020-06-22 15:41 pperry Note Added: 0006985
2020-06-22 15:59 pperry Note Added: 0006986
2020-06-22 16:00 pperry Status feedback => resolved
2020-06-22 16:00 pperry Resolution open => fixed