Bug 1497707

Summary: HypervisorUpdateJob should only ever run one instance per Org at a time
Product: [Community] Candlepin Reporter: Chris Snyder <csnyder>
Component: candlepinAssignee: candlepin-bugs
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.1CC: bcourt, candlepin-bugs, csnyder, katello-qa-list, mstead, redakkan, skallesh
Target Milestone: ---   
Target Release: 2.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: candlepin-2.3.1-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1497248 Environment:
Last Closed: 2019-04-04 13:15: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:
Bug Depends On: 1497248    
Bug Blocks:    

Description Chris Snyder 2017-10-02 13:40:31 UTC
+++ This bug was initially created as a clone of Bug #1497248 +++

If multiple requests are made to start an async hypervisor update to the same owner/org, candlepin will start the first, and queue up the other jobs to be run once the first has completed (WAITING state). Once the first job finishes, ALL other hypervisor update jobs that are in the WAITING state get triggered and run at the same time despite having the restriction of one checkin job can run per owner.

This can potentially allow these intensive jobs to queue up and upon execution and impact candlepin performance.


Steps to reproduce for candlepin:

1) To simulate a long checkin, put a sleep at the top of HypervisorUpdateJob.toExecute with start/end log before/after. Otherwise, make sure that the host/guest mappings in the curl command contain enough data to make the request take a bit of time to complete.

2) Tail the logs:
tail -f /var/log/candlepin/candlepin.log | grep "job=hypervisor_update"

3) Issue multiple simultaneous requests to start an async checkin via curl:

for i in {1..10}; do curl -k -u admin:admin -X POST -H "Content-Type: text/plain" -d '{"hypervisors":[]}' https://localhost:8443/candlepin/hypervisors/snowwhite; done


Results:

The log will show that the initial job will start. Once the job finishes, the log will show that the other 9 have been started together.

Expected Results:
The jobs should be executed one at a time in order of being created. The queuing  of the jobs should be allowed, but per owner, they should get run one at a time.