Bug 1341086

Summary: dnf install exists with 0 even if it did not install all packages
Product: [Fedora] Fedora Reporter: Jan Pazdziora <jpazdziora>
Component: dnfAssignee: Jaroslav Mracek <jmracek>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 25CC: ffesti, jmracek, jpazdziora, jsilhan, mluscon, packaging-team-maint, pnemade, vmukhame, zbyszek
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-02 15:20:33 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 Jan Pazdziora 2016-05-31 08:57:49 UTC
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 09:42:01 UTC
yes, looks like a bug...

Comment 2 Fedora Admin XMLRPC Client 2016-07-08 09:36:38 UTC
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 11:34:32 UTC
I created a PR: https://github.com/rpm-software-management/dnf/pull/552

Comment 4 Jaroslav Mracek 2016-07-29 11:44:09 UTC
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 10:20:32 UTC
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 09:45:27 UTC
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 12:25:19 UTC
*** Bug 1392061 has been marked as a duplicate of this bug. ***

Comment 8 Fedora End Of Life 2016-11-25 09:10:07 UTC
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 13:58:47 UTC
Issue still present with dnf-1.1.10-3.fc25.noarch.