Bug 1497248

Summary: HypervisorUpdateJob should only ever run one instance per Org at a time
Product: [Community] Candlepin Reporter: Michael Stead <mstead>
Component: candlepinAssignee: candlepin-bugs
Status: CLOSED CURRENTRELEASE QA Contact: Katello QA List <katello-qa-list>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 2.1CC: csnyder, redakkan, skallesh
Target Milestone: ---   
Target Release: 2.1   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: candlepin-2.1.6-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1497707 (view as bug list) Environment:
Last Closed: 2017-10-10 13:31:25 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:    
Bug Blocks: 1497707    

Description Michael Stead 2017-09-29 14:56:55 UTC
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.