Bug 1677840 - `dnf history undo last` doesn't work after update (keepcache=True)
Summary: `dnf history undo last` doesn't work after update (keepcache=True)
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: 29
Hardware: All
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-02-16 09:14 UTC by Kees de Jong
Modified: 2019-08-06 05:35 UTC (History)
10 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2019-02-18 13:24:07 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Kees de Jong 2019-02-16 09:14:24 UTC
Description of problem:
The undo feature of DNF doesn't work. Even with "keepcache=True" set in /etc/dnf/dnf.conf and the packages present in /var/cache/dnf.


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


Steps to Reproduce:
1. Enable "keepcache=True" in /etc/dnf/dnf.conf
2. Update packages
3. Try to undo the transaction with `dnf history undo last`
4. Run a find command to verify that missing packages are actually present in /var/cache/dnf, e.g. `find /var/cache/dnf -name "*kernel-headers-4.20.7-200.fc29.x86_64*"`

Actual results:
I get the following error when running `dnf history undo last`.

```
[root@defiant ~]# dnf history undo last                       
Last metadata expiration check: 0:31:52 ago on za 16 feb 2019 09:27:38 CET.
Undoing transaction 101, from za 16 feb 2019 09:54:43 CET        
    Install  kernel-4.20.8-200.fc29.x86_64               @updates
    Install  kernel-core-4.20.8-200.fc29.x86_64          @updates
    Install  kernel-modules-4.20.8-200.fc29.x86_64       @updates
    Upgrade  kernel-headers-4.20.8-200.fc29.x86_64       @updates
    Upgraded kernel-headers-4.20.7-200.fc29.x86_64       @@System
    Upgrade  kernel-tools-4.20.8-200.fc29.x86_64         @updates
    Upgraded kernel-tools-4.20.5-200.fc29.x86_64         @@System
    Upgrade  kernel-tools-libs-4.20.8-200.fc29.x86_64    @updates
    Upgraded kernel-tools-libs-4.20.5-200.fc29.x86_64    @@System
    Upgrade  libva-2.4.0-2.fc29.x86_64                   @updates
    Upgraded libva-2.3.0-1.fc29.x86_64                   @@System
    Upgrade  lorax-29.26-1.fc29.x86_64                   @updates
    Upgraded lorax-29.18-1.fc29.x86_64                   @@System
    Upgrade  lorax-templates-generic-29.26-1.fc29.x86_64 @updates
    Upgraded lorax-templates-generic-29.18-1.fc29.x86_64 @@System
    Upgrade  perf-4.20.8-200.fc29.x86_64                 @updates
    Upgraded perf-4.20.5-200.fc29.x86_64                 @@System
    Upgrade  python2-pyOpenSSL-19.0.0-1.fc29.noarch      @updates
    Upgraded python2-pyOpenSSL-18.0.0-3.fc29.noarch      @@System
    Upgrade  python3-perf-4.20.8-200.fc29.x86_64         @updates
    Upgraded python3-perf-4.20.5-200.fc29.x86_64         @@System
    Upgrade  python3-pyOpenSSL-19.0.0-1.fc29.noarch      @updates
    Upgraded python3-pyOpenSSL-18.0.0-3.fc29.noarch      @@System
    Upgrade  rpm-ostree-libs-2019.2-1.fc29.x86_64        @updates
    Upgraded rpm-ostree-libs-2019.1-1.fc29.x86_64        @@System                                                                                                                                                                                                                
    Removed  kernel-4.20.5-200.fc29.x86_64               @@System                                                                                                                                                                                                                
    Removed  kernel-core-4.20.5-200.fc29.x86_64          @@System                                                                                                                                                                                                                
    Removed  kernel-modules-4.20.5-200.fc29.x86_64       @@System
No package kernel-headers-4.20.7-200.fc29.x86_64 available.
No package kernel-tools-4.20.5-200.fc29.x86_64 available.                                                                                                                                                                                                                        
No package kernel-tools-libs-4.20.5-200.fc29.x86_64 available.
No package lorax-29.18-1.fc29.x86_64 available.
No package lorax-templates-generic-29.18-1.fc29.x86_64 available.
No package perf-4.20.5-200.fc29.x86_64 available.                                                                                                                                                                                                                                
No package python3-perf-4.20.5-200.fc29.x86_64 available.                                                                                                                                                                                                                        
No package rpm-ostree-libs-2019.1-1.fc29.x86_64 available.                                                                                                                                                                                                                       
Error: no package matched    
```

When checking for the "No package kernel-headers-4.20.7-200.fc29.x86_64 available." error, we can verify that this package is present in /var/cache/dnf.

```
# find /var/cache/dnf -name "*kernel-headers-4.20.7-200.fc29.x86_64*"                                                                                                                                                                                          
/var/cache/dnf/updates-0b4cc238d1aa4ffe/packages/kernel-headers-4.20.7-200.fc29.x86_64.rpm
```


Expected results:
DNF should be able to identify and use the packages stored in /var/cache/dnf. However, it fails to do this.


Additional info:
Interestingly, the package libva is found and is present in /var/cache/dnf. So DNF is able to walk through the directory and match packages. However, it fails to identify some of the other packages, such as the kernel-headers.

```
# find /var/cache/dnf -name "*libva-2.4.0-2.fc29.x86_64*"
/var/cache/dnf/updates-0b4cc238d1aa4ffe/packages/libva-2.4.0-2.fc29.x86_64.rpm
```

Comment 1 Marek Blaha 2019-02-18 13:24:07 UTC
On Fedora dnf history undo is not always possible. In this case package kernel-headers-4.20.7-200.fc29.x86_64 is no longer contained in fedora-updates repository metadata:

$ dnf repoquery --queryformat '%{name} %{evr} %{reponame}' kernel-headers
kernel-headers 4.18.16-300.fc29 fedora
kernel-headers 4.20.8-200.fc29 updates

So there is already newer package in updates repository.

But that is not the case of the libva package, where package you are trying to downgrade to still exists:
$ dnf repoquery --queryformat '%{name} %{evr} %{reponame}' libva
libva 2.3.0-1.fc29 fedora
libva 2.4.0-2.fc29 updates

Having packages in cache is not enough. You can try to use 'local' dnf plugin, which keeps all downloaded packages in local repository:
# dnf install dnf-plugin-local

I'm closing this as not a bug.

Comment 2 MIBESIS 2019-08-04 21:57:06 UTC
@Marek Blaha, not stictly related to this, but solution also does not work ( F31 ):

[root@hostname ~]# dnf install dnf-plugin-local
Last metadata expiration check: 1:59:35 ago on Sun 04 Aug 2019 09:48:22 PM CEST.
Dependencies resolved.
==============================================================================================================================================================================================================================================
 Package                                                              Architecture                                       Version                                                    Repository                                           Size
==============================================================================================================================================================================================================================================
Installing:
 python3-dnf-plugin-local                                             noarch                                             4.0.7-2.fc31                                               rawhide                                              17 k
Installing dependencies:
 createrepo_c                                                         x86_64                                             0.14.2-2.fc31                                              rawhide                                              73 k
 createrepo_c-libs                                                    x86_64                                             0.14.2-2.fc31                                              rawhide                                             106 k
 drpm                                                                 x86_64                                             0.3.0-19.fc31                                              rawhide                                              71 k
 libmodulemd                                                          x86_64                                             2.6.0-2.fc31                                               rawhide                                             187 k

Transaction Summary
==============================================================================================================================================================================================================================================
Install  5 Packages

Total download size: 455 k
Installed size: 1.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): createrepo_c-0.14.2-2.fc31.x86_64.rpm                                                                                                                                                                  133 kB/s |  73 kB     00:00    
(2/5): createrepo_c-libs-0.14.2-2.fc31.x86_64.rpm                                                                                                                                                             176 kB/s | 106 kB     00:00    
(3/5): drpm-0.3.0-19.fc31.x86_64.rpm                                                                                                                                                                          113 kB/s |  71 kB     00:00    
(4/5): libmodulemd-2.6.0-2.fc31.x86_64.rpm                                                                                                                                                                    1.7 MB/s | 187 kB     00:00    
(5/5): python3-dnf-plugin-local-4.0.7-2.fc31.noarch.rpm                                                                                                                                                       167 kB/s |  17 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                                                         297 kB/s | 455 kB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                                                                      1/1 
  Installing       : libmodulemd-2.6.0-2.fc31.x86_64                                                                                                                                                                                      1/5 
warning: Unable to get systemd shutdown inhibition lock: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.

  Installing       : drpm-0.3.0-19.fc31.x86_64                                                                                                                                                                                            2/5 
  Installing       : createrepo_c-libs-0.14.2-2.fc31.x86_64                                                                                                                                                                               3/5 
  Installing       : createrepo_c-0.14.2-2.fc31.x86_64                                                                                                                                                                                    4/5 
  Installing       : python3-dnf-plugin-local-4.0.7-2.fc31.noarch                                                                                                                                                                         5/5 
  Running scriptlet: python3-dnf-plugin-local-4.0.7-2.fc31.noarch                                                                                                                                                                         5/5 
  Verifying        : createrepo_c-0.14.2-2.fc31.x86_64                                                                                                                                                                                    1/5 
  Verifying        : createrepo_c-libs-0.14.2-2.fc31.x86_64                                                                                                                                                                               2/5 
  Verifying        : drpm-0.3.0-19.fc31.x86_64                                                                                                                                                                                            3/5 
  Verifying        : libmodulemd-2.6.0-2.fc31.x86_64                                                                                                                                                                                      4/5 
  Verifying        : python3-dnf-plugin-local-4.0.7-2.fc31.noarch                                                                                                                                                                         5/5 

Installed:
  python3-dnf-plugin-local-4.0.7-2.fc31.noarch             createrepo_c-0.14.2-2.fc31.x86_64             createrepo_c-libs-0.14.2-2.fc31.x86_64             drpm-0.3.0-19.fc31.x86_64             libmodulemd-2.6.0-2.fc31.x86_64            

Complete!
[root@hostname ~]# dnf update
_dnf_local                                                                                                                                                                                                    0.0  B/s |   0  B     00:00    
Failed to download metadata for repo '_dnf_local'
Error: Failed to download metadata for repo '_dnf_local'
[root@hostname ~]# dnf -v update
Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, local, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
DNF version: 4.2.7
cachedir: /var/cache/dnf
Unknown configuration value: failovermethod=priority in /etc/yum.repos.d/fedora-updates-modular.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Unknown configuration value: failovermethod=priority in /etc/yum.repos.d/fedora-updates-modular.repo; Configuration: OptionBinding with id "failovermethod" does not exist
Unknown configuration value: failovermethod=priority in /etc/yum.repos.d/fedora-updates-modular.repo; Configuration: OptionBinding with id "failovermethod" does not exist
repo: downloading from remote: _dnf_local
error: Curl error (37): Couldn't read a file:// file for file:///var/lib/dnf/plugins/local/repodata/repomd.xml [Couldn't open file /var/lib/dnf/plugins/local/repodata/repomd.xml] (file:///var/lib/dnf/plugins/local/repodata/repomd.xml).
error: Curl error (37): Couldn't read a file:// file for file:///var/lib/dnf/plugins/local/repodata/repomd.xml [Couldn't open file /var/lib/dnf/plugins/local/repodata/repomd.xml] (file:///var/lib/dnf/plugins/local/repodata/repomd.xml).
error: Curl error (37): Couldn't read a file:// file for file:///var/lib/dnf/plugins/local/repodata/repomd.xml [Couldn't open file /var/lib/dnf/plugins/local/repodata/repomd.xml] (file:///var/lib/dnf/plugins/local/repodata/repomd.xml).
error: Curl error (37): Couldn't read a file:// file for file:///var/lib/dnf/plugins/local/repodata/repomd.xml [Couldn't open file /var/lib/dnf/plugins/local/repodata/repomd.xml] (file:///var/lib/dnf/plugins/local/repodata/repomd.xml).
_dnf_local                                                                                                                                                                                                    0.0  B/s |   0  B     00:00    
Cannot download 'file:///var/lib/dnf/plugins/local': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried.
Failed to download metadata for repo '_dnf_local'
Error: Failed to download metadata for repo '_dnf_local'
[root@hostname ~]# ls -al /var/lib/dnf/plugins/local/repodata/repomd.xml
ls: cannot access '/var/lib/dnf/plugins/local/repodata/repomd.xml': No such file or directory
[root@hostname ~]# ls -al /var/lib/dnf/plugins/local/
ls: cannot access '/var/lib/dnf/plugins/local/': No such file or directory
[root@hostname ~]# ls -al /var/lib/dnf/
total 4344
drwxr-xr-x.  3 root root    4096 Aug  4 23:48 .
drwxr-xr-x. 23 root root    4096 Jul 25 02:35 ..
-rw-r--r--.  1 root root  270336 Aug  4 23:48 history.sqlite
-rw-r--r--.  1 root root   32768 Aug  4 23:48 history.sqlite-shm
-rw-r--r--.  1 root root 4132392 Aug  4 23:48 history.sqlite-wal
drwxr-xr-x.  2 root root    4096 Jul 27 21:40 modulefailsafe

TZ is CEST, system is updated with latest updates.

Comment 3 Marek Blaha 2019-08-06 05:35:13 UTC
This is error fixed in (not yet released) python3-dnf-plugin-local-4.0.8. (see details in the commit message https://github.com/rpm-software-management/dnf-plugins-core/commit/ba94209afb21b73f6abf67230ce9b9ca36e2ef4b). You can install and test it from our nightly repository (dnf copr enable rpmsoftwaremanagement/dnf-nightly).


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