Bug 1847124

Summary: Packagekit console client cannot refresh repo data due to undefined repo vars
Product: Red Hat Enterprise Linux 8 Reporter: Neal Gompa <ngompa13>
Component: PackageKitAssignee: Richard Hughes <rhughes>
Status: CLOSED WONTFIX QA Contact: Desktop QE <desktop-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: CentOS StreamCC: bmilar, bstinson, carl, darrin, davide, juanje, klember, rhughes, riehecky, sbarcomb, tpelka
Target Milestone: rcKeywords: Triaged
Target Release: 8.4   
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: 2021-12-15 07:27:12 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:
Attachments:
Description Flags
Backport fix to make dnf vars load properly
none
CentOS-Base.repo file none

Description Neal Gompa 2020-06-15 18:02:51 UTC
Description of problem:
When installing and configuring CentOS, the system is configured with repositories that PackageKit is unable to refresh. This is because PackageKit does not necessarily load all repository variable definitions before fetching repository metadata.

I'm unsure of how pervasively problematic this would be for RHEL, but it's a huge problem for CentOS.

Version-Release number of selected component (if applicable):
1.1.12-6.el8

How reproducible:
Always

Steps to Reproduce:
1. pkcon refresh force

Actual results:
Fatal error: cannot update repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Status code: 404 for http://mirror.internode.on.net/pub/$contentdir/8/BaseOS/x86_64/os/repodata/repomd.xml


Expected results:
Refresh should be successful.

Additional info:
I've made a fix in upstream PackageKit for this some time ago: https://github.com/hughsie/PackageKit/commit/ed73aa6317595d2c2f1bda7990cbd64efb133f84

Comment 1 Neal Gompa 2020-06-15 18:08:31 UTC
Note: I manually cloned this from the CentOS MantisBT (linked as an external bug) so that it can be properly tracked, and added information about the fix to make this easier to resolve.

Comment 2 Neal Gompa 2020-07-08 01:30:35 UTC
I've submitted this as a pull request to CentOS Stream: https://git.centos.org/rpms/PackageKit/pull-request/1

Comment 3 Carl George 🤠 2020-07-09 21:25:49 UTC
Created attachment 1700492 [details]
Backport fix to make dnf vars load properly

I've attached Neal's pull request here in patch form.  Because CentOS is still using the rpmbuild layout (SPECS and SOURCES directories), you'll need to use `patch -p2` to apply it to a flat tree (i.e. RHEL's dist-git).

Comment 4 Neal Gompa 2020-07-10 01:15:53 UTC
"git am -p2" will also work using the commit straight from the PR. :)

Comment 7 Bohdan Milar 2020-10-01 09:28:18 UTC
Could you please provide the repo file which caused the trouble, so I can test it on RHEL?

Comment 8 Neal Gompa 2020-10-02 12:57:33 UTC
Created attachment 1718445 [details]
CentOS-Base.repo file

(In reply to Bohdan Milar from comment #7)
> Could you please provide the repo file which caused the trouble, so I can
> test it on RHEL?

I've attached one of the CentOS repo files that demonstrates the issue.

Comment 9 Bohdan Milar 2020-10-09 18:49:51 UTC
Thanks for the repo file. Not having the gpgkey, I have disabled gpgcheck. Using the repo file in this form...

----
[BaseOS]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=BaseOS&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=0
enabled=1
----

... I got no error. Everything seemed to work.

I had to disable the mirrorlist line and enable "baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/" to reproduce the behavior. Then I got:

----
Fatal error: cannot update repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Status code: 404 for http://mirror.centos.org/$contentdir/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 109.228.54.129)
----

So it correctly replaced $releasever with 8 and $basearch with x86_64. The only unrecognized variable was $contentdir. But the same problem appears when using dnf:

----
$ dnf upgrade
...
CentOS-8 - Base                                                                                27 kB/s | 7.6 kB     00:00    
Errors during downloading metadata for repository 'BaseOS':
  - Status code: 404 for http://mirror.centos.org/$contentdir/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 109.228.54.129)
Error: Failed to download metadata for repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried
----

So I am not sure, whether it is a PackageKit bug.

Comment 10 Neal Gompa 2020-10-12 02:21:14 UTC
> So I am not sure, whether it is a PackageKit bug.


You need to have the dnf vars set up for DNF to work. Create /etc/dnf/vars/contentdir with the value of "centos".

Comment 11 Neal Gompa 2020-10-12 02:22:15 UTC
To be clear, the bug is that PackageKit doesn't read the vars set in /etc/dnf/vars. All the internally set ones work in PackageKit now ($releasever, $basearch).

Comment 12 Bohdan Milar 2020-10-14 09:00:48 UTC
OK, thanks.

So I used this reproducer:

1. echo "centos" >> /etc/dnf/vars/contentdir
2. cat > /etc/yum.repos.d/CentOS-Base.repo << EOF
[BaseOS]
name=CentOS-$releasever - Base
baseurl=http://mirror.centos.org/$contentdir/$releasever/BaseOS/$basearch/os/
gpgcheck=0
enabled=1
EOF
3. pkcon refresh force

Result:
Fatal error: cannot update repo 'BaseOS': Cannot download repomd.xml: Cannot download repodata/repomd.xml: All mirrors were tried; Last error: Status code: 404 for http://mirror.centos.org/$contentdir/8/BaseOS/x86_64/os/repodata/repomd.xml (IP: 62.141.54.220)

Additional info:
- PackageKit-1.1.12-6.el8.x86_64
- 'dnf --refresh check-upgrade' works fine.

Comment 13 Neal Gompa 2021-02-26 19:53:55 UTC
Hey, has anyone had a chance to look and act on this? I provided a patch, a test case, and it seems to be verified as an issue. So can we get this fix landed for RHEL 8.4?

Comment 14 Richard Hughes 2021-04-12 19:29:32 UTC
I think this needs to go into centos stream first, no?

Comment 15 Neal Gompa 2021-04-13 02:25:49 UTC
Yes it does, which is why I filed this bug report, provided a patch, and offered a test case so that it could land in CentOS Stream and make it in for RHEL 8.4. But now that RHEL 8.4 is in Beta, it'll probably slip and go into RHEL 8.5, assuming anything actually happens anytime soon...


*sigh*

Comment 17 Neal Gompa 2021-06-10 22:48:19 UTC
Ping? Can someone please look at this to get it fixed in RHEL 8.5?

Comment 20 Neal Gompa 2021-08-31 00:24:33 UTC
Friendly ping again? I'd *really* like this to land for RHEL 8.5...

Comment 22 Neal Gompa 2021-10-02 01:50:06 UTC
I've gone ahead and backported this myself for the CentOS Hyperscale Workstation since PackageKit being completely broken is unacceptable for our spin.

You can see the backport here: https://git.centos.org/rpms/PackageKit/c/ccbcd8ce4ec42d7d5d599d46cb32e95d2e627910?branch=c8s-sig-hyperscale

Comment 24 RHEL Program Management 2021-12-15 07:27:12 UTC
After evaluating this issue, there are no plans to address it further or fix it in an upcoming release.  Therefore, it is being closed.  If plans change such that this issue will be fixed in an upcoming release, then the bug can be reopened.