Bug 1689331

Summary: packagekit doesn't honor skip_if_unavailable=False for local repositories
Product: Red Hat Enterprise Linux 8 Reporter: Karel Srot <ksrot>
Component: libdnfAssignee: Jaroslav Rohel <jrohel>
Status: CLOSED ERRATA QA Contact: Karel Srot <ksrot>
Severity: medium Docs Contact:
Priority: high    
Version: 8.0CC: dmach, jkoten, jrohel, klember, tbowling, toneata
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libdnf-0.35.1-5.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1715209 (view as bug list) Environment:
Last Closed: 2019-11-05 22:21:30 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: 1716313    
Bug Blocks: 1715209    

Description Karel Srot 2019-03-15 16:15:15 UTC
Description of problem:

packagekit doesn't honor skip_if_unavailable=False for local repositories

# rpm -q libdnf PackageKit
libdnf-0.22.5-4.el8.x86_64
PackageKit-1.1.12-2.el8.x86_64

# cat /etc/yum.repos.d/modular.repo 
[modular-repo]
name=modular-repo
baseurl=file:///no/such/repo
#baseurl=http://foo.redhat.com/ModRepo
enabled=1
gpgcheck=0
skip_if_unavailable=False

# pkcon install TestA
Resolving                     [=====                    ] (21%)  Command failed: This tool could not find any available package: /no/such/repo was not found

don't give up, try again

# pkcon install TestA
Resolving                     [=========================]         
Finished                      [                         ] (0%)  
The following packages have to be installed:
 TestA-1-2.noarch	TestA Package
Proceed with changes? [N/y] 

The package above comes from a different repo, this should not be happening.

This is not happening for http repos

# cat /etc/yum.repos.d/modular.repo 
[modular-repo]
name=modular-repo
#baseurl=file:///no/such/repo
baseurl=http://foo.redhat.com/ModRepo
enabled=1
gpgcheck=0
skip_if_unavailable=False

# systemctl restart packagekit
# pkcon install TestA
Resolving                     [=====                    ] (21%)  Command failed: This tool could not find any available package: cannot update repo 'modular-repo': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Curl error (6): Couldn't resolve host name for http://foo.redhat.com/ModRepo/repodata/repomd.xml [Could not resolve host: foo.redhat.com]
# pkcon install TestA
Resolving                     [=====                    ] (21%)  Command failed: This tool could not find any available package: cannot update repo 'modular-repo': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Curl error (6): Couldn't resolve host name for http://foo.redhat.com/ModRepo/repodata/repomd.xml [Could not resolve host: foo.redhat.com]
# pkcon install TestA
Resolving                     [=====                    ] (21%)  Command failed: This tool could not find any available package: cannot update repo 'modular-repo': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Curl error (6): Couldn't resolve host name for http://foo.redhat.com/ModRepo/repodata/repomd.xml [Could not resolve host: foo.redhat.com]
# pkcon install TestA
Resolving                     [=====                    ] (21%)  Command failed: This tool could not find any available package: cannot update repo 'modular-repo': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Curl error (6): Couldn't resolve host name for http://foo.redhat.com/ModRepo/repodata/repomd.xml [Could not resolve host: foo.redhat.com]

Comment 2 Richard Hughes 2019-05-30 08:33:35 UTC
Does `skip_if_unavailable=0` work? I also think this is a libdnf bug, PK doesn't actually parse the file or manage the setting itself at all. I'll reassign, but feel free to re-assign back if I'm wrong. Thanks.

Comment 3 Karel Srot 2019-05-30 09:43:04 UTC
No, neither skip_if_unavailable=0 work.
While it may be libdnf issue, PackageKit is the only program where I can see this bug. Neither dnf nor microdnf is having this issue.

Adding more logs:

# rpm -q libdnf microdnf PackageKit dnf
libdnf-0.22.5-5.el8_0.x86_64
microdnf-3.0.1-1.el8.x86_64
PackageKit-1.1.12-2.el8.x86_64
dnf-4.0.9.2-5.el8.noarch

# cat /etc/yum.repos.d/testrepo-local.repo 
[testrepo-local]
name=testrepo-local
enabled=1
baseurl=file:///nosuchdir
gpgcheck=0
skip_if_unavailable=0

# systemctl restart packagekit
# pkcon install -v dummypkg
05:36:42	PackageKit          Verbose debugging enabled (on console 1)
05:36:42	PackageKit          filter=(null), filters=0
05:36:42	PackageKit          resolving 1 packages
05:36:42	PackageKit          role now resolve
Resolving                     [=====                    ] (21%)  Command failed: This tool could not find any available package: /nosuchdir was not found

# pkcon install -v dummypkg   # 2nd attempt triggers the issue
05:36:43	PackageKit          Verbose debugging enabled (on console 1)
05:36:43	PackageKit          filter=(null), filters=0
05:36:43	PackageKit          resolving 1 packages
05:36:43	PackageKit          role now resolve
Resolving                     [=========================]         05:36:43	PackageKit          adding state 0x55c442765020
05:36:43	PackageKit          doing install
05:36:43	PackageKit          role now install-packages
05:36:43	PackageKit          notify::connected
                              [=========================]         
Finished                      [                         ] (0%)  05:36:43	PackageKit          we got an untrusted message, so skipping only-trusted

The following packages have to be installed:
 dummypkg-1.0-1.noarch	dummypkg Package
Proceed with changes? [N/y] 

The transaction did not proceed.
                              [=========================]         
Testing changes               [                         ] (0%)  05:36:44	PackageKit          remove state 0x55c442765020
                              [=========================]         
Fatal error: user declined simulation
# 


# dnf install -y dummypkg
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.
testrepo-local                                                                                                                                    0.0  B/s |   0  B     00:00    
Error: Failed to synchronize cache for repo 'testrepo-local'
# dnf install -y dummypkg
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.
testrepo-local                                                                                                                                    0.0  B/s |   0  B     00:00    
Error: Failed to synchronize cache for repo 'testrepo-local'
# dnf install -y dummypkg
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.
testrepo-local                                                                                                                                    0.0  B/s |   0  B     00:00    
Error: Failed to synchronize cache for repo 'testrepo-local'
# microdnf install -y dummypkg
Downloading metadata...
error: /nosuchdir was not found
# microdnf install -y dummypkg
Downloading metadata...
error: /nosuchdir was not found
# microdnf install -y dummypkg
error: /nosuchdir was not found

Comment 10 Terry Bowling 2019-06-07 17:18:56 UTC
Setting zstream- as discussed with the team as it does not appear to be necessary.

Comment 11 Jaroslav Rohel 2019-06-10 10:38:50 UTC
The bug and the acceptance criteria combines more problems:

1. I found opposite problem in libdnf "libdnf context doesn't honor skip_if_unavailable=True for local repositories" https://bugzilla.redhat.com/show_bug.cgi?id=1716313 .
   I made fix for it: PR https://github.com/rpm-software-management/libdnf/pull/742

---
2. One of acceptance criteria is: skip_if_unavailable global option from /etc/dnf/dnf.conf works in PackageKit and microdnf.
   But libdnf does not read the global configuration file "/etc/dnf/dnf.conf". 
   OK, I implemented the new functionality loading of global configuration file: PR https://github.com/rpm-software-management/libdnf/pull/738

---
3. I tested the code with microdnf. It works OK. But there is still problem with PackageKit.
   I made tests. I damaged baseurl for repo "virtualbox". The repo has "skip_if_unavailable=false".

First try. Bug is reproduced.
# pkcon install iftop
Resolving                     [=========================]         
Testing changes               [=========================]         
Finished                      [                         ] (0%)  
The following packages have to be installed:
 iftop-1.0-0.18.pre4.fc29.x86_64        Command line tool that displays bandwidth usage on an interface
Proceed with changes? [N/y] 

Second try, with "-c 1". PackageKit stops on "virtualbox" repo now. It seems more complicated problem. Work with cache???
# pkcon install -c 1 iftop
Resolving                     [===                      ] (15%)  Command failed: This tool could not find any available package: cannot update repo 'virtualbox': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Status code: 404 for http://download.virtualbox.org/virtualbo/rpm/fedora/29/x86_64/repodata/repomd.xml
#

Comment 12 Karel Srot 2019-06-10 12:22:59 UTC
"-c 1" doesn't really work, according to my findings. Try "pkcon refresh force" instead.

Comment 13 Jaroslav Rohel 2019-06-12 11:54:55 UTC
I made PR that fixed the originally reported problem "packagekit doesn't honor skip_if_unavailable=False for local repositories".
https://github.com/rpm-software-management/libdnf/pull/750

All PR mentioned above are required for passing acceptance criteria.
https://github.com/rpm-software-management/libdnf/pull/738
https://github.com/rpm-software-management/libdnf/pull/742
https://github.com/rpm-software-management/libdnf/pull/750

Comment 17 errata-xmlrpc 2019-11-05 22:21:30 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, 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/RHSA-2019:3583