Bug 1613456

Summary: [RHEL76] It takes two invocations of "dnf-plugin-subscription-manager" to populate the redhat.repo file
Product: Red Hat Enterprise Linux 7 Reporter: Rehana <redakkan>
Component: subscription-managerAssignee: candlepin-bugs
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: medium Docs Contact:
Priority: high    
Version: 7.6CC: csnyder, jsefler, khowell
Target Milestone: rcKeywords: EasyFix, Triaged
Target Release: ---   
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: 2018-10-30 10:37:37 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: 1558411, 1615433    

Description Rehana 2018-08-07 15:19:14 UTC
Description of problem:
Observed that redhat.repo file was populated after running dnf repolist -d3 twice on the system . 

Note: You need to follow the below workaround to load the plugins the repos ; separate Bug 1613454 was logged to track this 

# echo 'pluginpath=/usr/lib64/python2.7/site-packages/dnf-plugins,/usr/lib/python2.7/site-packages/dnf-plugins' >> /etc/dnf/dnf.conf
[root@ibm-x3650m4-01-vm-12 pluginconf.d]# cat /etc/dnf/dnf.conf 
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
pluginpath=/usr/lib64/python2.7/site-packages/dnf-plugins,/usr/lib/python2.7/site-packages/dnf-plugins


dnf-plugin-subscription-manager-1.21.5-7.el7.x86_64

How reproducible:
Always

Steps to Reproduce:
1.Since yum and dnf can co-exist on RHEL76 , make sure the all the yum plugins are disabled (to make sure the dnf is not using the file that are already populated by yum ) 

[root@ibm-x3650m4-01-vm-12 pluginconf.d]# subscription-manager config --list | grep auto_enable
   auto_enable_yum_plugins = 0

[root@ibm-x3650m4-01-vm-12 pluginconf.d]# cat /etc/yum/pluginconf.d/search-disabled-repos.conf | grep enabled
enabled=0

[root@ibm-x3650m4-01-vm-12 pluginconf.d]# cat /etc/yum/pluginconf.d/subscription-manager.conf | grep enabled
enabled=0

[root@ibm-x3650m4-01-vm-12 pluginconf.d]# cat /etc/yum/pluginconf.d/product-id.conf | grep enabled
enabled=0

[root@ibm-x3650m4-01-vm-12 pluginconf.d]# subscription-manager unregister
This system is currently not registered.
[root@ibm-x3650m4-01-vm-12 pluginconf.d]# yum clean all 
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>

[root@ibm-x3650m4-01-vm-12 pluginconf.d]# dnf clean all
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.
8 files removed


2. Now register and auto-attach the system 
# subscription-manager register --auto-attach
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_test_rhel74
Password: 
The system has been registered with ID: 1f391b8f-c6d0-4f28-8598-5cd878b99595
The registered system name is: ibm-x3650m4-01-vm-12.lab.eng.bos.redhat.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

3) Delete the redhat.repo file ( only to be tried on rhel76, as the redhat.repo file is already populated by yum)

4) dnf replist -d3 
Observed the repos were not listed 

# dnf repolist -d3
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, product-id, repoclosure, repograph, repomanage, reposync, subscription-manager
DNF version: 2.7.5
cachedir: /var/cache/dnf
Updating Subscription Management repositories.
No repositories available

Trying again
# dnf repolist -d3
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, product-id, repoclosure, repograph, repomanage, reposync, subscription-manager
DNF version: 2.7.5
cachedir: /var/cache/dnf
Updating Subscription Management repositories.
Last metadata expiration check: 0:07:16 ago on Tuesday 07 August 2018 11:04:38 AM EDT.
repo id                                                                                    repo name                                                                                                         status
rhel-7-server-rpms                                          

Actual results:
Repos are now listed after second attempt

Expected results:
repos should be listed immediatly 


Additional info:

Comment 2 Chris Snyder 2018-08-09 14:20:50 UTC
@dev All we should need is a cherry pick of a3bd8ae27acd287c83c811a2e18da79629946bb0

Comment 3 Chris Snyder 2018-08-09 21:03:47 UTC
Correction the commit hash is: 4cee072dddd2df09b1d4076e978cba8cea2b2154

Comment 4 Chris Snyder 2018-08-16 18:09:44 UTC
The fix has been cherry-picked for the next build. Moving to POST.

Comment 6 Rehana 2018-08-20 10:14:40 UTC
Reproducer :
===========

# rpm -qa subsc* dnf* | sort
dnf-2.7.5-17.el7.noarch
dnf-data-2.7.5-17.el7.noarch
dnf-plugins-core-2.1.5-5.el7.noarch
dnf-plugin-subscription-manager-1.21.5-7.el7.x86_64
subscription-manager-1.21.5-7.el7.x86_64
subscription-manager-rhsm-1.21.5-7.el7.x86_64
subscription-manager-rhsm-certificates-1.21.5-7.el7.x86_64

1.Disable all yum plugins 

#subscription-manager config --list | grep auto_enable
   auto_enable_yum_plugins = 0

# cat /etc/yum/pluginconf.d/search-disabled-repos.conf | grep enabled
enabled=0
# Repositories matching the patterns listed in ignored_repos will not be
enabled by the plugin

# cat /etc/yum/pluginconf.d/subscription-manager.conf | grep enabled
enabled=0

# cat /etc/yum/pluginconf.d/product-id.conf | grep enabled
enabled=0

2. Register and attach subscription

# subscription-manager register --auto-attach
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_test_rhel74
Password: 
The system has been registered with ID: a2e95a09-359a-4b2b-a854-f656da1c9106
The registered system name is: ibm-x3650m4-01-vm-14.lab.eng.bos.redhat.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

3.Delete the redhat.repo populated 

# rm -rf /etc/yum.repos.d/redhat.repo

4.Execute dnf repolist

# dnf repolist -d3 
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install,
download, generate_completion_cache, needs-restarting, playground, repoclosure,
repograph, repomanage, reposync
DNF version: 2.7.5
cachedir: /var/cache/dnf
No repositories available

5. Add a workaround to load the plugins.

#echo 'pluginpath=/usr/lib64/python2.7/site-packages/dnf-plugins,/usr/lib/python2.7/site-packages/dnf-plugins' >> /etc/dnf/dnf.conf

6. # dnf repolist -d3 
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, product-id, repoclosure, repograph, repomanage, reposync, subscription-manager
DNF version: 2.7.5
cachedir: /var/cache/dnf
Updating Subscription Management repositories.
No repositories available

NO repositories were loaded

Try again

# dnf repolist -d3 
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, product-id, repoclosure, repograph, repomanage, reposync, subscription-manager
DNF version: 2.7.5
cachedir: /var/cache/dnf
Updating Subscription Management repositories.
Last metadata expiration check: 0:00:30 ago on Monday 20 August 2018 06:13:13 AM EDT.
repo id                                                                                    repo name                                                                                                         status
rhel-7-server-rpms                                                                         Red Hat Enterprise Linux 7 Server (RPMs)                                                                          20,891

On the second attempt the repositories were listed.

Comment 7 Rehana 2018-08-20 10:19:28 UTC
Verifying on :
===============
# rpm -qa subsc* dnf* | sort
dnf-2.7.5-17.el7.noarch
dnf-data-2.7.5-17.el7.noarch
dnf-plugins-core-2.1.5-5.el7.noarch
dnf-plugin-subscription-manager-1.21.7-1.el7.x86_64
subscription-manager-1.21.7-1.el7.x86_64
subscription-manager-rhsm-1.21.7-1.el7.x86_64
subscription-manager-rhsm-certificates-1.21.7-1.el7.x86_64

Note:Install dnf-plugin-subscription manager and its dependencies from Extras
repo.

1. Make sure all the yum plugin are disabled on the system 

# subscription-manager config --list | grep auto_enable
   auto_enable_yum_plugins = 0

# cat /etc/yum/pluginconf.d/search-disabled-repos.conf | grep enabled
enabled=0
# Repositories matching the patterns listed in ignored_repos will not be
enabled by the plugin

# cat /etc/yum/pluginconf.d/subscription-manager.conf | grep enabled
enabled=0

#  cat /etc/yum/pluginconf.d/product-id.conf | grep enabled
enabled=0

2. Register and attach subscription

# subscription-manager register --auto-attach
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: stage_test_rhel74
Password: 
The system has been registered with ID: 2dd800bd-4346-4cff-83d4-9714618696b6
The registered system name is: cisco-b22m3-01.rhts.eng.bos.redhat.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

3.Remove the redhat.repo file from the system 

# rm -rf redhat.repo

4.Execute dnf repolist -d3 ( note : Now that Bug 1613454 is fixed and verified, user need NOT to add the plugin path into dnf.conf file manually ) 

# dnf repolist -d3
Loaded plugins: builddep, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, needs-restarting, playground, product-id, repoclosure, repograph, repomanage, reposync, subscription-manager
Updating Subscription Management repositories.
DNF version: 2.7.5
cachedir: /var/cache/dnf
Updating Subscription Management repositories.
Last metadata expiration check: 0:39:59 ago on Monday 20 August 2018 05:38:04 AM EDT.
repo id                                                                                    repo name                                                                                                         status
rhel-7-server-rpms                                                                         Red Hat Enterprise Linux 7 Server (RPMs)                                                                          20,891

Plugins are now loaded and repos are listed successfully in the first attempt itself. 

Based on the above observations marking the bug as Verified.

Comment 9 errata-xmlrpc 2018-10-30 10:37:37 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/RHBA-2018:3153