Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1671815

Summary: [Satellite 6.3 Only] QPID connections remain open when HornetQ resends an event message after initial failure - connection count limit of 500 exceeded
Product: Red Hat Satellite Reporter: Mike McCune <mmccune>
Component: CandlepinAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED CURRENTRELEASE QA Contact: jcallaha
Severity: high Docs Contact:
Priority: medium    
Version: 6.3.5CC: bcourt, csnyder
Target Milestone: Unspecified   
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1579855 Environment:
Last Closed: 2019-04-09 12:48:34 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Mike McCune 2019-02-01 18:04:11 UTC
[ This bug only effects Satellite 6.3 and prior, it is resolved in the 6.4 version of Candlepin ]

+++ This bug was initially created as a clone of Bug #1579855 +++

+++ This bug was initially created as a clone of Bug #1546236 +++

After the initial attempt to send an event to Qpid fails, HornetQ will periodically resend the message to Qpid until it has been received. When the attempt to redeliver the event message fails, candlepin's connections to Qpid grow after each attempt until the max number of permissible connections have been made.

Once this occurs, this will prevent further communication with Qpidd; even from qpid tooling such as qpid-stat or qpid-config.


Steps To Reproduce
==================

1. Deploy candlepin with Qpid support.
deploy -gtaq

2. Stop Tomcat once deployed
sudo systemctl stop tomat

3. Disable candlepin's suspend mode /etc/candlepin/candlepin.conf
candlepin.suspend_mode_enabled=false

4. Disable SSL requirement for Qpidd so we can use the 'drain' tool
# Disable SSL in /etc/qpid/qpidd.conf
ssl-require-client-authentication=no

$ sudo systemctl restart qpidd

5. Re-configure the event queue and exchanges
# Delete the event queue and create a new one with configuration to enable flow stop (max-queue-size=16384).
# NOTE:  Run from the base candlepin checkout dir.
sudo qpid-config --ssl-certificate=server/bin/qpid/keys/candlepin.crt --ssl-key server/bin/qpid/keys/candlepin.key -b amqps://localhost:5671 del queue allmsg --force
sudo qpid-config --ssl-certificate=server/bin/qpid/keys/candlepin.crt --ssl-key server/bin/qpid/keys/candlepin.key -b amqps://localhost:5671 add queue allmsg --durable --max-queue-size=16384
sudo qpid-config --ssl-certificate=server/bin/qpid/keys/candlepin.crt --ssl-key server/bin/qpid/keys/candlepin.key -b amqps://localhost:5671 bind event allmsg '#'

6. Clean out any existing hornetQ data
$ sudo rm -rf /var/lib/candlepin/hornetq/*

7. Restart candlepin
sudo systemctl restart tomcat

8. Register a system to this candlepin (I used candlepin's test data)
sudo subscription-manager register -u admin -p admin --org admin

9. List the available subscriptions for this system, and make note of your favorite pool ID
$ sudo subscription-manager list --avail --all

10. List the details of the event queue. You should see that after registration a couple of events were put on the 'allmsg' queue.
$ sudo qpid-stat --ssl-certificate=server/bin/qpid/keys/candlepin.crt --ssl-key server/bin/qpid/keys/candlepin.key -b amqps://localhost:5671 -q allmsg

11. In a separate terminal, tail the candlepin log so that it can be monitored.
$ tail -f /var/log/candlepin/candlepin.log

12. Trigger an endless attach/unattach pattern for your registed system. Sub in the pool_id from above.
# while true; do subscription-manager remove --all; subscription-manager attach --pool=YOUR_FAV_POOL_ID; date; sleep 1; done

13. Watch the log file until you start seeing errors. This can take a few minutes to fill the Qpid queue to its configured max.

14. Once you start seeing the errors, check to make sure that HornetQ's queue starts to store the failed messages. You should see the message counts start to rise.
$ curl -k -u admin:admin https://localhost:8443/candlepin/admin/queues

16. Let the errros continue to occur, and monitor the connections that are made to Qpidd. Once HornetQ starts retrying these failed messages, you see the connection counts start to rise.

$ sudo netstat -anp | grep qpidd | grep -c ESTAB


Result:

Letting the failures continue to occur for a long period will eventually exhaust all connections, requiring a qpidd restart. Candlepin does not seem to be able to recover from this.

Expected Result:

Candlepin should better manange the connections that it opens to Qpid. If an exception happens while sending to Qpid, the connection should be closed, and re-opened on the next attempt.

Comment 3 Mike McCune 2019-02-01 18:09:19 UTC
WORKAROUND IF EXPERIENCING OUTAGES:

1) Edit /etc/candlepin/candlepin.conf 

2) set to false: candlepin.amqp.enable=false

3) Add 24 hour periodic cron job to refresh UI:

echo "0 8 * * * foreman /usr/sbin/foreman-rake katello:import_subscriptions >>/var/log/foreman/cron.log 2>&1" > /etc/cron.d/katello-refresh-subs

4) restart

katello-service restart

After putting Satellite in this configuration the UI for Content Hosts may show outdated subscription information if changes were made from the clients via 'subscription-manager' manually. These changes will be refreshed every 24 hours based on the cron configured above.

Comment 6 Mike McCune 2019-03-22 15:53:48 UTC
The symptom of this bug is often running out of connections in qpid and seeing error messages:

qpidd: [Security] error Client max total connection count limit of 500 exceeded by 'qpid.127.0.0.1:5671-127.0.0.1:39434', user: 'anonymous'. Connection refused

Comment 9 Mike McCune 2019-04-09 12:48:34 UTC
We are closing this bug as CLOSED:CURRENTRELEASE.  Backporting this fix to 6.3 is non-trivial and high risk. We have decided to rely on the resolution provide in 6.4.

Any customers experiencing this issue are first encouraged to upgrade to 6.4 to resolve the bug and if not immediately able, apply the WORKAROUND in comment #3.