Bug 1955480

Summary: D-Bus method Register() do not create redhat.repo, when SCA mode is used
Product: Red Hat Enterprise Linux 8 Reporter: Jiri Hnidek <jhnidek>
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.3CC: jsefler, jstavel, mkolman, redakkan
Target Milestone: betaKeywords: Triaged
Target Release: 8.6   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.28.28-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2031835 (view as bug list) Environment:
Last Closed: 2022-05-10 15:22:56 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: 1921131, 2031835    

Description Jiri Hnidek 2021-04-30 08:21:17 UTC
Description of problem:
When system is registered using D-Bus method Register() (Cockpit plugin or Anaconda plugin) and SCA mode is used, then calling Register() method does not populate redhat.repo with repository definitions, because SCA entitlement certificate is not obtained.


Version-Release number of selected component (if applicable):
server type: Red Hat Subscription Management
subscription management server: 3.2.11-1
subscription management rules: 5.41
subscription-manager: 1.29.5-1.git.7.a14a61b.el8

How reproducible:
100%

Steps to Reproduce:
1. Try to register system using following bash script. This script call D-Bus methods using dbus-send CLI. Note that organization snowwhite in this example uses SCA mode:


#!/bin/bash

# Create new unix socket used for registration 
echo "starting RegisterServer..."
dbus-send --system --print-reply --dest='com.redhat.RHSM1' \
        '/com/redhat/RHSM1/RegisterServer' com.redhat.RHSM1.RegisterServer.Start string:"" > /root/register_server_output.txt

if [[ $? -eq 0 ]]
then
        export my_addr=`cat /root/register_server_output.txt | gawk '/string/{ print $2 }' | sed 's/\"//g'`
fi

echo "Using address: $my_addr"

# Try to register using username and password
echo "registering using username and password and org..."
dbus-send --address=${my_addr} --print-reply --dest='com.redhat.RHSM1.Register' \
        '/com/redhat/RHSM1/Register' \
        com.redhat.RHSM1.Register.Register \
        string:"snowwhite" \
        string:"admin" \
        string:"admin" \
        dict:string:string:"","" \
        dict:string:string:"","" \
        string:"" > /root/register_output.txt

if [[ $? -eq 0 ]]
then
        echo "Registration sucess"
        export registered=1
else
        echo "Registration FAILED"
        export registered=0
fi

echo "stoping RegisterServer..."
dbus-send --system --print-reply --dest='com.redhat.RHSM1' \
        '/com/redhat/RHSM1/RegisterServer' com.redhat.RHSM1.RegisterServer.Stop string:"" > /dev/null


2. Check content of generated /etc/yum.repos.d/redhat.repo

[root@thinkpad-t580 subscription-manager]# cat /etc/yum.repos.d/redhat.repo 
#
# Certificate-Based Repositories
# Managed by (rhsm) subscription-manager
#
# *** This file is auto-generated.  Changes made here will be over-written. ***
# *** Use "subscription-manager repo-override --help" if you wish to make changes. ***
#
# If this file is empty and this system is subscribed consider
# a "yum repolist" to refresh available repos
#


Actual results: Empty redhat.repo file and no entitlement certificate installed in /etc/pki/entitlement


Expected results: redhat.repo file populated with definitions of repositories generated from installed SCA entitlement certificate.


Additional info:
Running following command fixes the issue. Calling AutoAttach() D-Bus method can also fix this issue, but it is strange to call auto-attach in SCA mode.

[root@thinkpad-t580 subscription-manager]# subscription-manager repos --list-enabled 
+----------------------------------------------------------+
    Available Repositories in /etc/yum.repos.d/redhat.repo
+----------------------------------------------------------+
Repo ID:   fake-content-38072
Repo Name: fake-content-38072
Repo URL:  http://svice:8080/path/to/fake-content/38072-3902
Enabled:   1

Repo ID:   awesomeos-deb-38070
Repo Name: awesomeos-deb-38070
Repo URL:  http://svice:8080/path/to/awesomeos-deb/38070-3901
Enabled:   1

Comment 11 errata-xmlrpc 2022-05-10 15:22:56 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 (subscription-manager bug fix and enhancement update), 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-2022:2047