Bug 1701290

Summary: dnf exits with non-zero exit code on broken UBI 8 repo access
Product: Red Hat Enterprise Linux 8 Reporter: Ken Dreyer (Red Hat) <kdreyer>
Component: dnfAssignee: Packaging Maintenance Team <packaging-team-maint>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: james.antill, mdomonko
Target Milestone: rc   
Target Release: 8.0   
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: 2019-04-29 11:46:10 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 Ken Dreyer (Red Hat) 2019-04-18 14:56:15 UTC
Description of problem:
DNF immediately exits with a "1" exit code if it cannot sync the cache on any broken repository.


Version-Release number of selected component (if applicable):
dnf-0.22.5-5.el8_0


How reproducible:
always

Steps to Reproduce:
1. Fire up the latest ubi8 container:

podman run -it --rm brew-pulp-docker01.web.prod.ext.phx2.redhat.com:8888\/ubi8:8.0-ondeck

2. Check the dnf version:

bash-4.4# rpm -qv libdnf
libdnf-0.22.5-4.el8.x86_64


3. Run "yum -y update", note the error strings:

bash-4.4# yum -y update
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.
Red Hat Universal Ba     [===                 ] ---  B/s |   0  B     --:-- ETA
Red Hat Universal Base Image 8 (RPMs) - AppStre 8.8  B/s |  16  B     00:01    
Red Hat Universal Base Image 8 (RPMs) - BaseOS   12  B/s |  16  B     00:01    
Failed to synchronize cache for repo 'ubi-8-appstream', ignoring this repo.
Failed to synchronize cache for repo 'ubi-8-baseos', ignoring this repo.
Dependencies resolved.
Nothing to do.

4. Note the exit code is zero with this dnf version:
bash-4.4# echo $?
0

5. Enable the RHEL 8 nightly repos
bash-4.4# cat /etc/yum.repos.d/rhel-8-nightly.repo 
[rhel-8-baseos-nightly]
name = RHEL 8 BaseOS nightly
baseurl = http://download.engineering.redhat.com/rhel-8/nightly/RHEL-8/latest-RHEL-8/compose/BaseOS/$basearch/os/
enabled = 1
gpgcheck = 0

[rhel-8-appstream-nightly]
name = RHEL 8 Appstream nightly
baseurl = http://download.engineering.redhat.com/rhel-8/nightly/RHEL-8/latest-RHEL-8/compose/AppStream/$basearch/os/
enabled = 1
gpgcheck = 0


6. Update libdnf to 0.22.5-5.el8_0
bash-4.4# yum -y update libdnf
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.
RHEL 8 Appstream nightly                        1.3 MB/s | 5.3 MB     00:04    
RHEL 8 BaseOS nightly                           698 kB/s | 2.2 MB     00:03    
Red Hat Universal Base Image 8 (RPMs) - AppStre 8.7  B/s |  16  B     00:01    
Red Hat Universal Base Image 8 (RPMs) - BaseOS   12  B/s |  16  B     00:01    
Failed to synchronize cache for repo 'ubi-8-appstream', ignoring this repo.
Failed to synchronize cache for repo 'ubi-8-baseos', ignoring this repo.
Last metadata expiration check: 0:00:01 ago on Thu Apr 18 14:52:53 2019.
Dependencies resolved.
================================================================================
 Package           Arch      Version             Repository                Size
================================================================================
Upgrading:
 libdnf            x86_64    0.22.5-5.el8_0      rhel-8-baseos-nightly    574 k
 python3-hawkey    x86_64    0.22.5-5.el8_0      rhel-8-baseos-nightly     86 k
 python3-libdnf    x86_64    0.22.5-5.el8_0      rhel-8-baseos-nightly    619 k

Transaction Summary
================================================================================
Upgrade  3 Packages
...

7. Try any other yum operation, eg "yum update" or "yum install python3-setuptools"



Actual results:

bash-4.4# yum update
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.
Red Hat Universal Base Image 8 (RPMs) - AppStre  13  B/s |  16  B     00:01    
Error: Failed to synchronize cache for repo 'ubi-8-appstream'

bash-4.4# echo $?
1


Expected results:
DNF should treat the broken repository as a non-fatal error and continue on with the command, whether that's "yum update" or "yum install", etc.

Additional info:
dnf-0.22.5-4.el8 is the last version I see that worked.

Comment 1 Ken Dreyer (Red Hat) 2019-04-18 15:15:00 UTC
I guess our workaround will be to delete the ubi.repo file for now.

Comment 2 Ken Dreyer (Red Hat) 2019-04-18 17:19:29 UTC
Here's our workaround that deletes ubi.repo: https://github.com/ceph/ceph-container/pull/1352