Limit the number of active requests at one time

We have CloudForms connected to a RHEV engine. We have many users that use the CloudForms API to automate service provisioning/retirement tasks, usually from a Jenkins server. We occasionally see instances where CloudForms receives 20 or more new service provisioning requests around the same time. CloudForms seems to handle all of these requests at once. This eventually overwhelms our RHEV engine and creates a storage issues among our VMs.

Currently, we have disabled auto approvals in CloudForms and have an external script query RHEV and CloudForms. If the RHEV engine’s task count is low enough, then the script will approve up to five requests in CloudForms at a time.

I’m trying to find a way to limit the number of active requests in Cloudforms, but I haven’t been successful. Could someone help point me in right direction?

Thanks!

Requests have a request_state attribute that is “active” for an active request, so in your approval state machine you could potentially search for the number of active requests using something like:

$evm.vmdb(:miq_request).where(:request_state => 'active')

If this was above a threshold you could introduce a wait-and-retry state until this value dropped, and then auto approve the request.

Hope this helps,
pemcg

Thanks, pemcg!

I implemented something, based on your suggestions, and it seems to be working correctly!