Bug 1289166

Summary: dnf makecache triggers a python exception
Product: [Fedora] Fedora Reporter: Michael S. Tsirkin <mst>
Component: dnfAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: jmracek, jsilhan, mluscon, mst, packaging-team-maint, pnemade, ppisar, vmukhame
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dnf-1.1.6-1.fc23 dnf-1.1.6-2.fc22 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-02-17 04:23:18 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 Michael S. Tsirkin 2015-12-07 15:06:49 UTC
Description of problem:
ever since I upgraded to Fedora 23,
dnf makecache crashes.

My dnf.conf:
[mst@robin ~]$ cat /etc/dnf/dnf.conf 
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
metadata_expire=never
metadata_timer_sync=0

Applying the below patch helps.

$ diff -u makecache.py /usr/lib/python3.4/site-packages/dnf/cli/commands/makecache.py
--- makecache.py        2015-12-07 17:05:01.751919279 +0200
+++ /usr/lib/python3.4/site-packages/dnf/cli/commands/makecache.py      2015-12-07 17:05:05.282858626 +0200
@@ -69,7 +69,7 @@
 
         for r in self.base.repos.iter_enabled():
             (is_cache, expires_in) = r.metadata_expire_in()
-            if not is_cache or expires_in <= 0:
+            if not is_cache or expires_in == None or expires_in <= 0:
                 logger.debug('%s: has expired and will be refreshed.', r.id)
                 r.md_expire_cache()
             elif timer and expires_in < period:


Version-Release number of selected component (if applicable):
dnf-1.1.4-2.fc23.noarch

How reproducible:
always

Steps to Reproduce:
1. sudo dnf makecache

Actual results:
$ dnf makecache
Traceback (most recent call last):
  File "/usr/bin/dnf", line 57, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 174, in user_main
    errcode = main(args)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 60, in main
    return _main(base, args)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 112, in _main
    cli.run()
  File "/usr/lib/python3.4/site-packages/dnf/cli/cli.py", line 1091, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python3.4/site-packages/dnf/cli/commands/makecache.py", line 72, in run
    if not is_cache or expires_in <= 0:
TypeError: unorderable types: NoneType() <= int()


Expected results:
should create a cache

Additional info:

Comment 1 Michael S. Tsirkin 2015-12-07 15:07:30 UTC
I'm pretty sure this is something in my setup.
Just could not figure out what it is.

Comment 2 Jaroslav Mracek 2015-12-08 14:08:42 UTC
Thank you for report, we will look at it

Comment 3 Jaroslav Mracek 2015-12-08 14:09:59 UTC
*** Bug 1289449 has been marked as a duplicate of this bug. ***

Comment 4 Jaroslav Mracek 2015-12-10 14:47:56 UTC
I am sorry but we cannot reproduce it. Please could you provide condition or settings that will trigger the error. On virtual machine with upgraded f22 to f23 (standard settings) we were unable to reproduce it even with yours dnf.conf setting.

Comment 5 Michael S. Tsirkin 2015-12-10 19:05:54 UTC
I'm not sure what you are looking for.
this must be some configuration file.

It's 100% reproducible so can't you write a patch to add
some print statements in main.py and cli.py
to see where does expires_in come from?
I'll gladly apply it and give you the result.

It's not surprising this does not trigger
on a fresh install, this machine has been
updated over time all the way from probably f18
and some config files have been manually
tweaked in between.

Could be yum.conf?

$ cat /etc/yum.conf 
[main]
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=3
http_caching=none

arch=i686
basearch=i386

mdpolicy=group:all
mddownloadpolicy=sqlite
metadata_expire_filter=read-only:future
metadata_expire=never
#  This is the default, if you make this bigger yum won't see if the metadata
# is newer on the remote and so you'll "gain" the bandwidth of not having to
# download the new metadata and "pay" for it by yum not having correct
# information.
#  It is esp. important, to have correct metadata, for distributions like
# Fedora which don't keep old packages around. If you don't like this checking
# interupting your command line usage, it's much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

Comment 6 Petr Pisar 2015-12-11 08:23:30 UTC
I haven't tried it in fresh new installation, but I can reproduced in any installation (F23 or F24) I have by these steps:

(1) Add metadata_expire=never into main section of /etc/dnf/dnf.conf.
(2) Remove metadata_expire=6h from an enabled repository.
(3) Run "dnf clean metadata"
(4) Run "dnf makecache". This succeeds.
(5) Run "dnf makecache" again. This fails with the backtrace.

Comment 7 Honza Silhan 2015-12-14 12:43:05 UTC
Pert, thanks for reproducer, we will take a look.

Comment 8 Jaroslav Mracek 2016-01-05 09:41:46 UTC
The new pull-request was made (https://github.com/rpm-software-management/dnf/pull/420) that should fix the problem.

Comment 9 Fedora Update System 2016-01-26 10:34:41 UTC
dnf-plugins-core-0.1.16-1.fc23 dnf-1.1.6-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2016-80cbf309b4

Comment 10 Fedora Update System 2016-01-26 10:35:53 UTC
dnf-plugins-core-0.1.16-1.fc22 dnf-1.1.6-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-573eba7b37

Comment 11 Fedora Update System 2016-01-26 19:52:54 UTC
dnf-1.1.6-1.fc23, dnf-plugins-core-0.1.16-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-80cbf309b4

Comment 12 Fedora Update System 2016-01-28 18:20:14 UTC
dnf-1.1.6-1.fc23, dnf-plugins-core-0.1.16-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.

Comment 13 Fedora Update System 2016-01-28 23:19:31 UTC
dnf-1.1.6-1.fc22, dnf-plugins-core-0.1.16-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-573eba7b37

Comment 14 Fedora Update System 2016-02-03 13:06:59 UTC
dnf-1.1.6-2.fc22 dnf-plugins-core-0.1.16-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2016-573eba7b37

Comment 15 Fedora Update System 2016-02-03 23:27:03 UTC
dnf-1.1.6-2.fc22, dnf-plugins-core-0.1.16-1.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-573eba7b37

Comment 16 Fedora Update System 2016-02-17 04:22:23 UTC
dnf-1.1.6-2.fc22, dnf-plugins-core-0.1.16-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.