Bug 1341086 - dnf install exists with 0 even if it did not install all packages
dnf install exists with 0 even if it did not install all packages
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
25
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jaroslav Mracek
Fedora Extras Quality Assurance
: Triaged
: 1392061 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-31 04:57 EDT by Jan Pazdziora
Modified: 2016-12-02 10:20 EST (History)
9 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-12-02 10:20:33 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Jan Pazdziora 2016-05-31 04:57:49 EDT
Description of problem:

man dnf(8) says:

       dnf [options] install <spec>...
              DNF makes sure that the given packages  and  their  dependencies
              are  installed  on  the  system.  Each  <spec>  can  be either a
              <package-spec>, or a @<group-spec>. See Install Examples.  If  a
              given  package  or  provide  cannot  be  (and  is  not  already)
              installed, the exit code will be non-zero.

That does not seem to be the case when the package installation fails due to cpio error, for example.

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

dnf-1.1.6-2.fc23.noarch

How reproducible:

Deterministic.

Steps to Reproduce:
1. docker run --rm -ti fedora:23 dnf install -y opencryptoki ; echo $?

Actual results:

$ docker run --rm -ti fedora:23 dnf install -y opencryptoki
Fedora 23 - x86_64                               58 MB/s |  43 MB     00:00    
Fedora 23 - x86_64 - Updates                     51 MB/s |  22 MB     00:00    
Last metadata expiration check performed 0:00:11 ago on Tue May 31 08:53:10 2016.
Dependencies resolved.
================================================================================
 Package                    Arch         Version            Repository     Size
================================================================================
Installing:
 opencryptoki               x86_64       3.4.1-1.fc23       updates       101 k
 opencryptoki-icsftok       x86_64       3.4.1-1.fc23       updates       228 k
 opencryptoki-libs          x86_64       3.4.1-1.fc23       updates        45 k

Transaction Summary
================================================================================
Install  3 Packages

Total download size: 373 k
Installed size: 1.0 M
Downloading Packages:
(1/3): opencryptoki-libs-3.4.1-1.fc23.x86_64.rp 351 kB/s |  45 kB     00:00    
(2/3): opencryptoki-3.4.1-1.fc23.x86_64.rpm     780 kB/s | 101 kB     00:00    
(3/3): opencryptoki-icsftok-3.4.1-1.fc23.x86_64 1.4 MB/s | 228 kB     00:00    
--------------------------------------------------------------------------------
Total                                           167 kB/s | 373 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Installing  : opencryptoki-libs-3.4.1-1.fc23.x86_64                       1/3 
  Installing  : opencryptoki-icsftok-3.4.1-1.fc23.x86_64                    2/3 
  Installing  : opencryptoki-3.4.1-1.fc23.x86_64                            3/3 
Error unpacking rpm package opencryptoki-3.4.1-1.fc23.x86_64
Error unpacking rpm package opencryptoki-3.4.1-1.fc23.x86_64
error: unpacking of archive failed on file /var/lock/opencryptoki: cpio: mkdir
opencryptoki-3.4.1-1.fc23.x86_64 was supposed to be installed but is not!
  Verifying   : opencryptoki-3.4.1-1.fc23.x86_64                            1/3 
  Verifying   : opencryptoki-libs-3.4.1-1.fc23.x86_64                       2/3 
  Verifying   : opencryptoki-icsftok-3.4.1-1.fc23.x86_64                    3/3 

Installed:
  opencryptoki-icsftok.x86_64 3.4.1-1.fc23                                      
  opencryptoki-libs.x86_64 3.4.1-1.fc23                                         

Failed:
  opencryptoki.x86_64 3.4.1-1.fc23                                              

Complete!
$ echo $?
0

Expected results:

The exit status should be 1.

Additional info:

Due to bug 1341079, package is not installed, dnf even reports is in the "Failed" section, but still exists with 0.

This breaks container image builds because in build time, RUN commands exit with success and then the image does not contain what it is supposed to and what the author expects.
Comment 1 Igor Gnatenko 2016-06-06 05:42:01 EDT
yes, looks like a bug...
Comment 2 Fedora Admin XMLRPC Client 2016-07-08 05:36:38 EDT
This package has changed ownership in the Fedora Package Database.  Reassigning to the new owner of this component.
Comment 3 Jaroslav Mracek 2016-07-29 07:34:32 EDT
I created a PR: https://github.com/rpm-software-management/dnf/pull/552
Comment 4 Jaroslav Mracek 2016-07-29 07:44:09 EDT
The PR description - It returns 1 if one or more packages were not installed or removed (was supposed to be installed but is not!), but there is not roll-back of transaction, therefore correctly installed packages are still present on system.
Comment 5 Jaroslav Mracek 2016-10-14 06:20:32 EDT
Probably we can still improve the verification of packages on RPM level. Please Florian can you share with us your opinion for the bugzila and proposed patch? Any information provided will be very helpful.
Comment 6 Florian Festi 2016-10-24 05:45:27 EDT
Well, the error handling on the rpm level is not that great. It skips subsequent related transaction members like the removals of failed updates but that's basically all it does. So returning 1 and reporting the error is probably the best thing dnf can do unless rpm grows some better recovery mechanisms.
Comment 7 Jaroslav Mracek 2016-11-07 07:25:19 EST
*** Bug 1392061 has been marked as a duplicate of this bug. ***
Comment 8 Fedora End Of Life 2016-11-25 04:10:07 EST
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.
Comment 9 Jan Pazdziora 2016-11-25 08:58:47 EST
Issue still present with dnf-1.1.10-3.fc25.noarch.

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