Bug 1787197

Summary: rhsmcertd-worker fires as many RHSM queries as number of enabled repos
Product: Red Hat Enterprise Linux 8 Reporter: Pavel Moravec <pmoravec>
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED NOTABUG QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 8.1CC: bcourt, csnyder, dsynk, jhnidek, lmiksik, wclark
Target Milestone: rcKeywords: Triaged
Target Release: 8.1   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-02-10 10:13: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:

Description Pavel Moravec 2020-01-01 11:05:51 UTC
Description of problem:
Having many repos enabled on a system, various RHSM tasks take longer - linearly to the number of enabled repos (even custom ones). Particular tasks/requests that take longer:

(*) rhsmcertd-worker doing certs check (by default, every 4hours)
(*) subscription-manager repos --list
(*) subscription-manager repos --[enable|disable]=..
(*) subscription-manager attach --pool=..

For _each_ enabled repo, below requests are raised:

1.2.3.4 - - [01/Jan/2020:11:46:50 +0100] "GET /rhsm/consumers/a396bdc4-ed28-402d-831b-96d8cae1b0ae/certificates/serials HTTP/1.1" 200 63 "-" "RHSM/1.0 (cmd=rhsmcertd-worker)"
1.2.3.4 - - [01/Jan/2020:11:46:50 +0100] "GET /rhsm/status HTTP/1.1" 200 377 "-" "RHSM/1.0 (cmd=rhsmcertd-worker)"
1.2.3.4 - - [01/Jan/2020:11:46:50 +0100] "GET /rhsm/consumers/a396bdc4-ed28-402d-831b-96d8cae1b0ae HTTP/1.1" 200 22271 "-" "RHSM/1.0 (cmd=rhsmcertd-worker)"
1.2.3.4 - - [01/Jan/2020:11:46:50 +0100] "GET /rhsm/consumers/a396bdc4-ed28-402d-831b-96d8cae1b0ae/content_overrides HTTP/1.1" 200 2980 "-" "RHSM/1.0 (cmd=rhsmcertd-worker)"
1.2.3.4 - - [01/Jan/2020:11:46:50 +0100] "GET /rhsm/consumers/a396bdc4-ed28-402d-831b-96d8cae1b0ae/release HTTP/1.1" 200 19 "-" "RHSM/1.0 (cmd=rhsmcertd-worker)"


Having 50 repos enabled, 50 such bunches of requests are made. Invoking those requests by thousands of clients then generates redundantly high load to Satellite (as well as to our customer portal candlepin instance).

RHSM (subscription-manager / rhsmcertd / .. programs) should rather cache the data during one invocation since the very first query, and re-use the information.


Version-Release number of selected component (if applicable):
Sat6.6.1 / subscription-manager-rhsm-1.24.13-3.el7_7.x86_64


How reproducible:
100%


Steps to Reproduce:
1. Create 10+ custom products and repos.
2. Enable all of them (plus some Red Hat repo) on a client system
3. Run either command:
rhsmcertd-worker   ( or wait for the automated certs check itself)
subscription-manager repos --list
subscription-manager repos --[enable|disable]=..
subscription-manager attach --pool=..

4. meanwhile, check requests made against Satellite:

tail -f /var/log/httpd/foreman-ssl_access_ssl.log



Actual results:
The five requests enumerated above will be fired against Satellite as many times as the number of enabled repos is.


Expected results:
Ideally, there should be just one such bunch of requests.


Additional info:
This is rather RHEL/rhsm bug / improvement request, though it mainly affects Satellite customers - let engineering decides proper product and component.

Comment 9 Jiri Hnidek 2020-01-27 16:57:49 UTC
I can confirm that this bug has been already fixed here: https://bugzilla.redhat.com/show_bug.cgi?id=1741183

The #1741183 is already in ON_QA state.

Comment 12 Pavel Moravec 2020-02-10 10:11:02 UTC
Backport to RHEL8 is _not_ needed as this BZ affects yum systems but not dnf ones.


This does not happen in RHEL8 / on dnf systems, as dnf must cache its config somehow. Cf the fix

https://github.com/candlepin/subscription-manager/pull/2204/files

and mimic the underlying calls manually.

On RHEL7 when I run a python script:

import yum
yb = yum.YumBase()
yb.conf

(what exactly _obtain_mappings_yum did before the patch), then:
1) I see "Loaded plugins: product-id, subscription-manager" (cf. the bz1741183 complaint)
2) the latest call "yb.conf" triggers 5 requests against RHSM server (to URIs for /rhsm/, /rhsm/status, and for consumer serials, content_overrides + release)

This is executed for each repo enabled when running my reproducer.


On RHEL8 when I run python script:

import dnf
db = dnf.dnf.Base()
db.conf

then no requests are raised against RHSM server, at all.

This means that both this bz1787197 and bz1741183 are applicable to yum systems but not dnf systems.



So the backport of bz1741183 fix to RHEL8 is not required.

Comment 13 Pavel Moravec 2020-02-10 10:13:37 UTC
Due to the above statement, no bug on RHEL8 (while RHEL7 is tracked under 1741183). So closing this as NOTABUG (on rhel8).