Bug 1683134

Summary: dnf rollback works strange after upgrade/downgrade/remove
Product: Red Hat Enterprise Linux 8 Reporter: Karel Srot <ksrot>
Component: dnfAssignee: Daniel Mach <dmach>
Status: CLOSED ERRATA QA Contact: Jan Blazek <jblazek>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: amatej, james.antill, mdomonko, pkratoch
Target Milestone: rcKeywords: Triaged
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libdnf-0.48.0-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 01:52:20 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:
Bug Depends On:    
Bug Blocks: 1825061    

Description Karel Srot 2019-02-26 10:10:03 UTC
Description of problem:

While testing the reproducer from bug 1614346 I did found out that dnf rollback behaves strange and the actions suggested doesn't match the expected state.

SETUP

[root@host-8-250-243 ~]# yum -y -q install foo-2.0
[root@host-8-250-243 ~]# yum -y -q downgrade foo-1.0
[root@host-8-250-243 ~]# yum -y -q upgrade foo-2.0
[root@host-8-250-243 ~]# rpm -q foo
foo-2.0-1.noarch

# yum history list last-3..last
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    49 | -y -q upgrade foo-2.0    | 2019-02-26 04:56 | Upgrade        |    1   
    48 | -y -q downgrade foo-1.0  | 2019-02-26 04:56 | Downgrade      |    1   
    47 | -y -q install foo-2.0    | 2019-02-26 04:56 | Install        |    1   
    46 | install aide             | 2019-02-26 04:56 | Install        |    1   

ACTION1:

# yum history list last-3..last
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository beaker-client-testing is listed more than once in the configuration
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    49 | -y -q upgrade foo-2.0    | 2019-02-26 04:56 | Upgrade        |    1   
    48 | -y -q downgrade foo-1.0  | 2019-02-26 04:56 | Downgrade      |    1   
    47 | -y -q install foo-2.0    | 2019-02-26 04:56 | Install        |    1   
    46 | install aide             | 2019-02-26 04:56 | Install        |    1   
[root@host-8-250-243 ~]# yum history rollback 46
Rollback to transaction 46, from Tue 26 Feb 2019 04:56:07 AM EST
  Undoing the following transactions: 47, 48, 49
    Install foo-2.0-1.noarch @foo
Dependencies resolved.
================================================================================
 Package         Arch               Version              Repository        Size
================================================================================
Removing:
 foo             noarch             2.0-1                @foo               0  

Transaction Summary
================================================================================
Remove  1 Package

Freed space: 0  
Is this ok [y/N]: 
Operation aborted.

This is expected and matches the expectation from bug 1614346.

ACTION2

# yum history rollback 47
Rollback to transaction 47, from Tue 26 Feb 2019 04:56:24 AM EST
  Undoing the following transactions: 48, 49
    Upgraded foo-1.0-1.noarch @@System
Dependencies resolved.
================================================================================
 Package          Arch                Version            Repository        Size
================================================================================
Downgrading:
 foo              noarch              1.0-1              foo              6.4 k

Transaction Summary
================================================================================
Downgrade  1 Package

Total size: 6.4 k
Is this ok [y/N]: 
Operation aborted.

The downgrade here is unexpected as the state after 47 was foo-2.0 installed.

ACTION3
# yum history rollback 48
Rollback to transaction 48, from Tue 26 Feb 2019 04:56:35 AM EST
  Undoing the following transactions: 49
    Upgraded foo-1.0-1.noarch @@System
    Upgrade  foo-2.0-1.noarch @foo
Dependencies resolved.
================================================================================
 Package          Arch                Version            Repository        Size
================================================================================
Downgrading:
 foo              noarch              1.0-1              foo              6.4 k

Transaction Summary
================================================================================
Downgrade  1 Package

Total size: 6.4 k
Is this ok [y/N]: 

This is expected.

ACTION4:
# yum -y -q remove foo
# yum -y -q install foo
# yum -y -q remove foo
# yum history list last-3..last
ID     | Command line             | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    52 | -y -q remove foo         | 2019-02-26 05:05 | Removed        |    1   
    51 | -y -q install foo        | 2019-02-26 05:04 | Install        |    1   
    50 | -y remove foo            | 2019-02-26 05:03 | Removed        |    1   
    49 | -y -q upgrade foo-2.0    | 2019-02-26 04:56 | Upgrade        |    1   

# yum history rollback 50
Rollback to transaction 50, from Tue 26 Feb 2019 05:03:53 AM EST
  Undoing the following transactions: 51, 52
    Install foo-2.0-1.noarch @foo
No package foo-2.0-1.noarch installed.
Error: no package matched

This is again unexpected. foo is not installed and after 50 it also was not installed. So there should not be any error and the action should rather result in Nothing to do.

Version-Release number of selected component (if applicable):
dnf-4.0.9.2-5.el8.noarch
libdnf-0.22.5-4.el8.x86_64

Comment 3 Vratislav Hutsky 2020-01-08 09:01:56 UTC
Restoring previous qa_ack+ as agreed earlier.

Comment 12 errata-xmlrpc 2020-11-04 01:52:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (yum bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2020:4510