Bug 1722954

Summary: Slow performance when running "hammer host list" with a high number of Content Hosts (15k+ for example)
Product: Red Hat Satellite Reporter: Aldrey Souza <alsouza>
Component: HostsAssignee: Oleh Fedorenko <ofedoren>
Status: CLOSED ERRATA QA Contact: tstrych
Severity: medium Docs Contact:
Priority: high    
Version: 6.5.0CC: apatel, egolov, inecas, jcallaha, kgaikwad, mbacovsk, mshira, ofedoren, rabajaj, wpinheir
Target Milestone: 6.8.0Keywords: Performance, Triaged
Target Release: Unused   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: tfm-rubygem-hammer_cli-0.20.0,tfm-rubygem-hammer_cli_foreman-2.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-10-27 12:58:39 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 Aldrey Souza 2019-06-21 19:54:53 UTC
Description of problem:

After register a huge number of Content Hosts (15+) on Satellite we can see a long time to finish the command "hammer host list" and the customer is complaining about that.

Version-Release number of selected component (if applicable):
6.5.z

How reproducible:
100%


Steps to Reproduce:
1. Register 15k content hosts
2. Run the command: "hammer host list"

Actual results:
Spending a long time to finish

Expected results:
Faster output

Additional info:

Comment 3 Aldrey Souza 2019-06-21 20:11:04 UTC
On local lab was used the script below to reregister the machine with diff UUID and FQDN 40K times. At this moment we have ~15k and we are able to face the slow behavior.


// Script executed on a Content Host
===
#!/bin/bash
{
 
for SEQ in {00001..40000}
do
 NODEUUID=$(uuidgen)
 NODEHOST="node${SEQ}.local.domain"
 cat << _EOF_ > /etc/rhsm/facts/host.facts
{
  "dmi.system.uuid":"${NODEUUID}",
  "virt.uuid":"${NODEUUID}",
  "network.fqdn":"${NODEHOST}",
  "network.hostname":"${NODEHOST}",
  "uname.nodename":"${NODEHOST}"
}
_EOF_
 echo "Register: HOST [${NODEHOST}]  - UUID [${NODEUUID}] - TIME [$(date)]"
 subscription-manager register --org="EXAMPLE" --username=admin --password=redhat --environment=Library
 echo -e "===============  TIME [$(date)] ===============\n"
 find /etc/pki/consumer/ -type f -delete
done
 
} 2>&1 | tee -a create_hosts.log
===

Note. On this scenario, the org is EXAMPLE.

Aldrey Souza

Comment 6 jcallaha 2019-06-28 15:57:48 UTC
Depending on what you are using hammer host list for, you can drastically reduce execution time by using the --thin option. 

For example, using Waldirio's reproducer, "--thin 1" reduced execution time from 13m11s to 1m3s.

# time hammer host list --thin 1
real	1m3.263s
user	0m22.975s
sys	0m1.427s

Of course, only the host's id and name are included in the output, but additional commands could follow up to gather more detailed information.

Comment 10 Bryan Kearney 2019-11-20 19:05:19 UTC
Upstream bug assigned to ofedoren

Comment 11 Bryan Kearney 2019-11-20 19:05:21 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/17819 has been resolved.

Comment 12 tstrych 2020-06-19 19:34:28 UTC
Not sure if we resolve the root of the problem here, but next text in this comment would about be about verification of upstream fix in downstream. 

if sat has more than 1000 hosts
hammer host list - after hammer host list fetches 1000 hosts it will show them

On example:
with 3345 hosts
1. firstly you saw nothing
2. after 1000 thousand host is fetched, you can see header and 1000 hosts, (wc -l == 1003)
3. after another 1000 fetched, it shows 2000 hosts, (wc -l == 2003)
4. same again, it shows 3000 hosts, (wc -l == 3003) 
5. lastly, 345 hosts is fetched, you can see them all, 3345 hosts is showed, (wc -l == 3348), command ends. 
Easy as that. 

This was verified with 5309 hosts and these steps:
1. hammer host list  > hammer_host_list.txt &
2. as fast as possible after 1.  ( choose the bigger number to rather stop later, my sat shows 5000 host under 200 seconds in all runs)
 for i in {1..<number>}; do echo $i; sleep 1; wc -l hammer_host_list.txt; done

result: 
1
0 hammer_host_list.txt
2
0 hammer_host_list.txt
---------<omitted>-------
26
0 hammer_host_list.txt
27
1003 hammer_host_list.txt
---------<omitted>-------
54
1003 hammer_host_list.txt
55
2003 hammer_host_list.txt
---------<omitted>-------
81
2003 hammer_host_list.txt
---------<omitted>-------
82
2003 hammer_host_list.txt
83
3003 hammer_host_list.txt
---------<omitted>-------
107
3003 hammer_host_list.txt
108
4003 hammer_host_list.txt
---------<omitted>-------
135
4003 hammer_host_list.txt
136
5003 hammer_host_list.txt
---------<omitted>-------
143
5003 hammer_host_list.txt
144
[1]+  Done                    hammer host list > hammer_host_list.txt
5312 hammer_host_list.txt

it is approximately 30s per 1000 hosts. 

using sat 6.8 snap 4

Verified.

Comment 15 errata-xmlrpc 2020-10-27 12:58:39 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 (Important: Satellite 6.8 release), 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/RHSA-2020:4366