Bug 2122621

Summary: Auto-attach does not recognize ELS repositories during subscription attachment
Product: Red Hat Satellite Reporter: Taft Sanders <tasander>
Component: CandlepinAssignee: Barnaby Court <bcourt>
Status: CLOSED DUPLICATE QA Contact: Lai <ltran>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.9.9CC: nmoumoul
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-09-19 12:47:27 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 Taft Sanders 2022-08-30 12:59:21 UTC
Description of problem:
When using auto-attach on a system to register (either with an activation key, --auto-attach, or attach --auto, candlepin does not recognize the ELS repositories as provided by the entitlement or product 204.

Version-Release number of selected component (if applicable):
candlepin-3.1.28-1.el7sat.noarch

How reproducible:
Every time

Steps to Reproduce:
1. Register a RHEL 6 system to a Satellite with ONLY separated subscriptions for RHEL (69) and RHEL ELS (204) in any quantity. Ensure no subscription that provides both products is on the Satellite. SCA is disabled (entitlement mode)
2. Register the RHEL 6 client to the Satellite with any method that provides auto-attach
3. Observe the RHEL 6 client obtain 2 subscriptions (1 for RHEL and 1 for RHEL ELS) with the ELS subscription not providing any content for ELS repositories

Actual results:
ELS subscription is generated on the Satellite without any repositories:
[root@drone610 ~]# subscription-manager remove --all
2 local certificates have been deleted.
2 subscriptions removed at the server.
[root@drone610 ~]# ls /etc/pki/entitlement/
[root@drone610 ~]# ll /etc/pki/entitlement/
total 0
[root@drone610 ~]# subscription-manager list
+-------------------------------------------+
    Installed Product Status
+-------------------------------------------+
Product Name:   Red Hat Enterprise Linux Server
Product ID:     69
Version:        6.10
Arch:           x86_64
Status:         Not Subscribed
Status Details: Not supported by a valid subscription.
Starts:         
Ends:           

Product Name:   Red Hat Enterprise Linux Server - Extended Life Cycle Support
Product ID:     204
Version:        6.10
Arch:           x86_64
Status:         Not Subscribed
Status Details: Not supported by a valid subscription.
Starts:         
Ends:           

[root@drone610 ~]# subscription-manager attach --auto
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

Product Name: Red Hat Enterprise Linux Server - Extended Life Cycle Support
Status:       Subscribed

[root@drone610 ~]# subscription-manager list --consumed | grep -i SKU
SKU:                 RH00270S
SKU:                 MCT3718
[root@drone610 ~]# ll /etc/pki/entitlement/
total 16
-rw-------. 1 root root 3243 Aug 30 08:46 3407714449716543020-key.pem
-rw-r--r--. 1 root root 2810 Aug 30 08:46 3407714449716543020.pem
-rw-------. 1 root root 3243 Aug 30 08:46 9219942106558908193-key.pem
-rw-r--r--. 1 root root 3765 Aug 30 08:46 9219942106558908193.pem
[root@drone610 ~]# rct cat-cert /etc/pki/entitlement/3407714449716543020.pem 

+-------------------------------------------+
	Entitlement Certificate
+-------------------------------------------+

Certificate:
	Path: /etc/pki/entitlement/3407714449716543020.pem
	Version: 3.4
	Serial: 3407714449716543020
	Start Date: 2021-12-01 05:00:00+00:00
	End Date: 2022-12-01 04:59:59+00:00
	Pool ID: 8a919595820f4fba01826a07f0a3096a

Subject:
	CN: 7d80bf3834e3455490f2a20ec6360c03
	O: Default_Organization

Issuer:
	C: US
	CN: satellite.example.com
	L: Raleigh
	O: Katello
	OU: SomeOrgUnit
	ST: North Carolina

Product:
	ID: 204
	Name: Red Hat Enterprise Linux Server - Extended Life Cycle Support
	Version: 
	Arch: x86_64,ia64,x86
	Tags: 
	Brand Type: 
	Brand Name: 

Order:
	Name: Red Hat Enterprise Linux Extended Life Cycle Support (Physical or Virtual Nodes)
	Number: 40567045
	SKU: RH00270S
	Contract: 11111111
	Account: 111111
	Service Level: Layered
	Service Type: L1-L3
	Quantity: 44
	Quantity Used: 1
	Socket Limit: 2
	RAM Limit: 
	Core Limit: 
	Virt Only: False
	Stacking ID: RH00270S
	Warning Period: 0
	Provides Management: False

[root@drone610 ~]# 


Expected results:
For the subscription to have the ELS repositories.

Additional info:
If the client does a sub-man refresh the subscription is recreated on the Satellite side and the ELS repositories are included as expected:

[root@drone610 ~]# ll /etc/pki/entitlement/
total 16
-rw-------. 1 root root 3243 Aug 30 08:46 3407714449716543020-key.pem
-rw-r--r--. 1 root root 2810 Aug 30 08:46 3407714449716543020.pem
-rw-------. 1 root root 3243 Aug 30 08:46 9219942106558908193-key.pem
-rw-r--r--. 1 root root 3765 Aug 30 08:46 9219942106558908193.pem
[root@drone610 ~]# subscription-manager refresh
2 local certificates have been deleted.
All local data refreshed
[root@drone610 ~]# ll /etc/pki/entitlement/
total 16
-rw-------. 1 root root 3243 Aug 30 08:55 3574143451708627915-key.pem
-rw-r--r--. 1 root root 3765 Aug 30 08:55 3574143451708627915.pem
-rw-------. 1 root root 3243 Aug 30 08:55 4210934231638828094-key.pem
-rw-r--r--. 1 root root 3257 Aug 30 08:55 4210934231638828094.pem
[root@drone610 ~]# rct cat-cert /etc/pki/entitlement/4210934231638828094.pem 

+-------------------------------------------+
	Entitlement Certificate
+-------------------------------------------+

Certificate:
	Path: /etc/pki/entitlement/4210934231638828094.pem
	Version: 3.4
	Serial: 4210934231638828094
	Start Date: 2021-12-01 05:00:00+00:00
	End Date: 2022-12-01 04:59:59+00:00
	Pool ID: 8a919595820f4fba01826a07f0a3096a

Subject:
	CN: 7d80bf3834e3455490f2a20ec6360c03
	O: Default_Organization

Issuer:
	C: US
	CN: satellite.example.com
	L: Raleigh
	O: Katello
	OU: SomeOrgUnit
	ST: North Carolina

Product:
	ID: 204
	Name: Red Hat Enterprise Linux Server - Extended Life Cycle Support
	Version: 
	Arch: x86_64,ia64,x86
	Tags: 
	Brand Type: 
	Brand Name: 

Order:
	Name: Red Hat Enterprise Linux Extended Life Cycle Support (Physical or Virtual Nodes)
	Number: 40567045
	SKU: RH00270S
	Contract: 11111111
	Account: 111111
	Service Level: Layered
	Service Type: L1-L3
	Quantity: 44
	Quantity Used: 1
	Socket Limit: 2
	RAM Limit: 
	Core Limit: 
	Virt Only: False
	Stacking ID: RH00270S
	Warning Period: 0
	Provides Management: False

Content:
	Type: yum
	Name: Red Hat Enterprise Linux 6 Server - Extended Life Cycle Support - Optional (RPMs)
	Label: rhel-6-server-els-optional-rpms
	Vendor: Red Hat
	URL: /Default_Organization/PRD/RHEL6/content/els/rhel/server/6/6Server/$basearch/optional/os
	GPG: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
	Enabled: False
	Expires: 1
	Required Tags: rhel-6-server
	Arches: x86_64, x86

Content:
	Type: yum
	Name: Red Hat Enterprise Linux 6 Server - Extended Life Cycle Support (RPMs)
	Label: rhel-6-server-els-rpms
	Vendor: Red Hat
	URL: /Default_Organization/PRD/RHEL6/content/els/rhel/server/6/6Server/$basearch/os
	GPG: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
	Enabled: False
	Expires: 1
	Required Tags: rhel-6-server
	Arches: x86_64, x86

Comment 1 Taft Sanders 2022-08-30 13:40:18 UTC
Looking at the candlepin logs during the creation of the certificate I see the following message:

--snip--
2022-08-29 13:46:04,612 [thread=http-bio-127.0.0.1-23443-exec-2] [req=301fdf54-0e88-4458-b424-e0278e425f07, org=Default_Organization, csid=] INFO  org.candlepin.service.impl.DefaultEntitlementCertServiceAdapter - Creating X509 cert for product: Product [uuid: 8a8c56c57ba170fc017ba1802fec0053, id: RH00270, name: Red Hat Enterprise Linux Extended Life Cycle Support (Physical or Virtual Nodes)]
2022-08-29 13:46:04,612 [thread=http-bio-127.0.0.1-23443-exec-2] [req=301fdf54-0e88-4458-b424-e0278e425f07, org=Default_Organization, csid=] DEBUG org.candlepin.service.impl.DefaultEntitlementCertServiceAdapter - Provided products: [Product [uuid: 8a8c56c57ba170fc017ba1802fec0053, id: RH00270, name: Red Hat Enterprise Linux Extended Life Cycle Support (Physical or Virtual Nodes)], Product [uuid: 8a8d6277818bb8fc01818bc338230213, id: 204, name: Red Hat Enterprise Linux Server - Extended Life Cycle Support]]

**HERE**
2022-08-29 13:46:04,643 [thread=http-bio-127.0.0.1-23443-exec-2] [req=301fdf54-0e88-4458-b424-e0278e425f07, org=Default_Organization, csid=] DEBUG org.candlepin.util.X509Util - No entitlements found for modified products.
2022-08-29 13:46:04,643 [thread=http-bio-127.0.0.1-23443-exec-2] [req=301fdf54-0e88-4458-b424-e0278e425f07, org=Default_Organization, csid=] DEBUG org.candlepin.util.X509Util - Skipping content set: Content [uuid: 8a8c56c578f5a3020178f5dac216039b, id: 7396, name: Red Hat Enterprise Linux 6 Server - Extended Life Cycle Support (RPMs), label: rhel-6-server-els-rpms]
2022-08-29 13:46:04,643 [thread=http-bio-127.0.0.1-23443-exec-2] [req=301fdf54-0e88-4458-b424-e0278e425f07, org=Default_Organization, csid=] DEBUG org.candlepin.util.X509Util - Skipping content not promoted to environment: {}Content [uuid: 8a8c56c578f5a3020178f5dac216039d, id: 7398, name: Red Hat Enterprise Linux 6 Server - Extended Life Cycle Support (ISOs), label: rhel-6-server-els-isos]
--snip--

I will include the full log for better context if necessary as an attachment (candlepin.out)