Bug 1278382 - DNF python programming error when run from virt-builder
Summary: DNF python programming error when run from virt-builder
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 23
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1280034 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-11-05 11:28 UTC by James (purpleidea)
Modified: 2016-01-04 19:52 UTC (History)
10 users (show)

Fixed In Version: dnf-1.1.4-2.fc23 dnf-1.1.4-2.fc22 dnf-1.1.5-1.fc23 dnf-1.1.5-1.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-12-22 21:59:26 UTC


Attachments (Terms of Use)
full log from virt-builder on F21 (122.43 KB, text/plain)
2015-11-10 19:44 UTC, James (purpleidea)
no flags Details
full log from virt-builder on F23 (128.85 KB, text/plain)
2015-11-10 19:45 UTC, James (purpleidea)
no flags Details


Links
System ID Priority Status Summary Last Updated
Red Hat Bugzilla 1280029 None None None Never

Internal Links: 1280029

Description James (purpleidea) 2015-11-05 11:28:56 UTC
Description of problem:

Running a dnf install -y <package> produces an error when run from virt-builder:

Dependencies resolved.
================================================================================
 Package               Arch         Version                 Repository     Size
================================================================================
Installing:
 gssproxy              x86_64       0.4.1-3.fc23            updates        87 k
 keyutils              x86_64       1.5.9-7.fc23            fedora         60 k
 libbasicobjects       x86_64       0.1.1-27.fc23           fedora         29 k
 libcollection         x86_64       0.7.0-27.fc23           fedora         45 k
 libevent              x86_64       2.0.21-7.fc23           fedora        217 k
 libini_config         x86_64       1.2.0-27.fc23           fedora         64 k
 libnfsidmap           x86_64       0.26-3.1.fc23           fedora         51 k
 libpath_utils         x86_64       0.2.1-27.fc23           fedora         31 k
 libref_array          x86_64       0.1.5-27.fc23           fedora         30 k
 libtalloc             x86_64       2.1.3-1.fc23            fedora         42 k
 libtevent             x86_64       0.9.25-2.fc23           fedora         36 k
 libtirpc              x86_64       0.3.2-3.0.fc23          fedora        100 k
 libverto-tevent       x86_64       0.2.6-5.fc23            fedora         14 k
 nfs-utils             x86_64       1:1.3.2-11.fc23         fedora        367 k
 quota                 x86_64       1:4.02-4.fc23           fedora        170 k
 quota-nls             noarch       1:4.02-4.fc23           fedora         94 k
 rpcbind               x86_64       0.2.3-0.2.fc23          fedora         63 k
 rsync                 x86_64       3.1.1-7.fc23            fedora        392 k
 screen                x86_64       4.3.1-2.fc23            fedora        571 k
 tar                   x86_64       2:1.28-6.fc23           fedora        944 k
 tcp_wrappers          x86_64       7.6-81.fc23             fedora         84 k
Skipping packages with conflicts:
(add '--best --allowerasing' to command line to force their upgrade):
 openssh               x86_64       7.1p1-4.fc23            updates       443 k
 openssh-clients       x86_64       7.1p1-4.fc23            updates       633 k
 openssh-server        x86_64       7.1p1-4.fc23            updates       459 k

Transaction Summary
================================================================================
Install  21 Packages

Total download size: 3.4 M
Installed size: 8.8 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           527 kB/s | 3.4 MB     00:06     
warning: /var/cache/dnf/fedora-fe3d2f0c91e9b65c/packages/rsync-3.1.1-7.fc23.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 34ec9cba: NOKEY
The downloaded packages were saved in cache till the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Traceback (most recent call last):
  File "/bin/dnf", line 35, in <module>
    main.user_main(sys.argv[1:], exit_code=True)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 198, in user_main
    errcode = main(args)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 84, in main
    return _main(base, args)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 144, in _main
    ret = resolving(cli, base)
  File "/usr/lib/python3.4/site-packages/dnf/cli/main.py", line 173, in resolving
    base.do_transaction(display=displays)
  File "/usr/lib/python3.4/site-packages/dnf/cli/cli.py", line 220, in do_transaction
    self.gpgsigcheck(downloadpkgs)
  File "/usr/lib/python3.4/site-packages/dnf/cli/cli.py", line 251, in gpgsigcheck
    if not sys.stdin.isatty() and not ay:
AttributeError: 'NoneType' object has no attribute 'isatty'
virt-builder: error: dnf -y install 'rsync' 'nfs-utils' 'sudo' 
'openssh-server' 'openssh-clients' 'screen' 'tar': command exited with an 
error



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

How reproducible:
100%

Should be fairly straightforward to understand the error from the python traceback. Someone oopsed :P

Comment 1 James (purpleidea) 2015-11-10 19:44:26 UTC
Created attachment 1092401 [details]
full log from virt-builder on F21

Comment 2 James (purpleidea) 2015-11-10 19:45:10 UTC
Created attachment 1092402 [details]
full log from virt-builder on F23

Comment 3 James (purpleidea) 2015-11-10 19:45:31 UTC
Full logs and easy reproducer attached.

Comment 4 Richard W.M. Jones 2015-11-10 20:27:28 UTC
*** Bug 1280034 has been marked as a duplicate of this bug. ***

Comment 5 Adam Williamson 2015-11-17 22:10:21 UTC
Note that the affected dnf code is from 2011, so I suspect it's virt-builder or even python that changed something here (presumably it used to happen such that sys.stdin was set), not DNF. But the DNF code could reasonably handle the case where sys.stdin is None, yes.

Comment 6 Adam Williamson 2015-11-17 23:06:56 UTC
https://github.com/rpm-software-management/dnf/pull/384

Comment 7 Richard W.M. Jones 2015-11-17 23:37:19 UTC
No dispute that it's a bug in virt-builder (bug 1280029).  However
it would be nice if dnf was a bit more robust.  The patch you
posted looks good to me.

Comment 8 Fedora Update System 2015-11-27 11:25:37 UTC
dnf-1.1.4-2.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-93db5cd342

Comment 9 Fedora Update System 2015-11-27 11:26:15 UTC
dnf-1.1.4-2.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-d060fec064

Comment 10 Fedora Update System 2015-11-27 22:21:04 UTC
dnf-1.1.4-2.fc22 has been pushed to the Fedora 22 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update dnf'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-d060fec064

Comment 11 Fedora Update System 2015-11-28 02:19:49 UTC
dnf-1.1.4-2.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update dnf'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-93db5cd342

Comment 12 Fedora Update System 2015-11-28 20:21:59 UTC
dnf-1.1.4-2.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 2015-11-30 23:21:05 UTC
dnf-1.1.4-2.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.

Comment 14 Richard W.M. Jones 2015-12-01 13:13:19 UTC
A new virt-builder Fedora 23 image has been uploaded that
includes dnf-1.1.4-2.fc23.

https://github.com/libguestfs/libguestfs/commit/59ea51d358e4e4d8c8ef6535760fcfc9bfe0a3a3

Comment 15 Mateusz Guzik 2015-12-02 15:21:28 UTC
The patch looks incorrect, or rather, insufficient.

Normally all programs assume fds 0, 1 and 2 are open.

Making the code more robust in case of weird circumstances is definitely a nice idea. However, just checking stdin in one place which may or may not need it does not look right.

If stdin is missing, chances are stdout and stderr are missing too. Then, as you open/close file descriptors, you may end up with an important output file on fd 2 (stderr) and proceed to corrupt it because of some unrelated error.

The patched function is not the only place using stdin right now (although the only using 'stdin' as the object), and the code is likely to get more in the future.

As such, if such checks are considered valuable, they have to be done at the start program unconditionally. If exiting straight up seems too harsh, one can then try to remedy the situation by opening /dev/null for all missing fds. But if even that fails, it is too dangerous to continue due to aforementioned problems.

Comment 16 Fedora Update System 2015-12-18 17:46:46 UTC
dnf-plugins-core-0.1.15-1.fc23 dnf-1.1.5-1.fc23 has been submitted as an update to Fedora 23. https://bodhi.fedoraproject.org/updates/FEDORA-2015-c72cd24fa0

Comment 17 Fedora Update System 2015-12-18 17:48:34 UTC
dnf-plugins-core-0.1.15-1.fc22 dnf-1.1.5-1.fc22 has been submitted as an update to Fedora 22. https://bodhi.fedoraproject.org/updates/FEDORA-2015-1bb112ccc6

Comment 18 Fedora Update System 2015-12-19 19:59:27 UTC
dnf-1.1.5-1.fc23, dnf-plugins-core-0.1.15-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report.
If you want to test the update, you can install it with
$ su -c 'dnf --enablerepo=updates-testing update dnf dnf-plugins-core'
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2015-c72cd24fa0

Comment 19 Fedora Update System 2015-12-22 15:35:09 UTC
dnf-1.1.5-1.fc22, dnf-plugins-core-0.1.15-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-2015-1bb112ccc6

Comment 20 Fedora Update System 2015-12-22 21:58:42 UTC
dnf-1.1.5-1.fc23, dnf-plugins-core-0.1.15-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 21 Fedora Update System 2016-01-04 19:52:00 UTC
dnf-1.1.5-1.fc22, dnf-plugins-core-0.1.15-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.