Bug 1534589 - Quota fails when an active Service request contains an Invalid service_template.
Summary: Quota fails when an active Service request contains an Invalid service_template.
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.8.0
Hardware: Unspecified
OS: Unspecified
urgent
urgent
Target Milestone: GA
: 5.8.3
Assignee: Tina Fitzgerald
QA Contact: Ganesh Hubale
URL:
Whiteboard:
Depends On: 1531914
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-01-15 14:15 UTC by Satoe Imaishi
Modified: 2022-07-09 09:13 UTC (History)
12 users (show)

Fixed In Version: 5.8.3.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 1531914
Environment:
Last Closed: 2018-02-28 13:13:19 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1533217 0 urgent CLOSED Quota fails when an active Service request contains an Invalid service_template. 2021-03-11 16:52:53 UTC
Red Hat Knowledge Base (Solution) 3312341 0 None None None 2018-01-15 14:15:38 UTC
Red Hat Product Errata RHSA-2018:0374 0 normal SHIPPED_LIVE Important: Red Hat CloudForms security, bug fix, and enhancement update 2018-02-28 18:04:37 UTC

Internal Links: 1533217

Comment 2 CFME Bot 2018-01-15 14:21:30 UTC
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/7de622587cc1a162178b6ccf9d78f2188522d3f9

commit 7de622587cc1a162178b6ccf9d78f2188522d3f9
Author:     Greg McCullough <gmccullo>
AuthorDate: Tue Jan 9 15:30:37 2018 -0500
Commit:     Satoe Imaishi <simaishi>
CommitDate: Mon Jan 15 09:14:46 2018 -0500

    Merge pull request #16769 from tinaafitz/quota_mixin_service_template_fix
    
    Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template.
    (cherry picked from commit 8aa881f53bfa3ae2517921bbd061d82d01ccd600)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1534589

 app/models/mixins/miq_provision_quota_mixin.rb               | 1 +
 spec/models/service_template_provision_request_quota_spec.rb | 6 ++++++
 2 files changed, 7 insertions(+)

Comment 4 Tina Fitzgerald 2018-01-17 13:17:18 UTC
Hi Vatsal,

The core issue here is that check_quota(:active_provisions) fails when it encounters an active Service request that has an invalid service_template.
  
We recently changed the active_provision code to calculate quota values for Service requests by looking at the request service_template.service_resource information.
 
The customer has multiple multiple zones and had Service requests queued to a zone where work never got dispatched because the automate role was not enabled there. Since these Service requests were active, they were included in the quota active calculations. Several of these Service requests had invalid service_templates(meaning the service_template used when the Service was originally ordered no longer exists). 

Although this issue impacts any calls to the check_quota(:active_provisions) method, the customer encountered it in the request.check_quota(:active_provisions) call during VM provisioning here:
RedHat Automate domain method:
/Infrastructure/VM/Provisioning/Placement/vmware_best_fit_with_scope
Since the vmware_best_fit_with_scope method is used during VM Provisioning, all provisions would fail if the active_quota calculations encountered a single Service MiqRequest with an invalid service_template, even if Quota is not being used.

To reproduce this issue: (You'll need to have the RedHat Automate domain) 
1. Setup multiple zones.(You can use a single appliance and just add a "test" zone)
2. Add VMWare provider and configure it to the "test" zone.  
3. Create a VMWare Service Item.
4. Order the Service.
5. Delete the Service Template used in the Service creation in step 3.
6. Modify the VMWare provider to use the default zone. (This should leave the existing Service request(s) in the queue for the "test" zone and the service_template will be invalid)
7. Provision a VMWare VM.  
You should see the following error in the log:
"[----] E, [2018-01-06T11:11:20.073924 #13027:e0ffc4] ERROR -- : Q-task_id([miq_provision_787]) MiqAeServiceModelBase.ar_method raised: <NoMethodError>: <undefined method `service_resources' for nil:NilClass>
[----] E, [2018-01-06T11:11:20.074019 #13027:e0ffc4] ERROR -- : Q-task_id([miq_provision_787]) "

*Note - The steps above will reproduce the issue with Quota turned off. 
With Quota turned on, any type of provisioning should fail in Quota with the same error, so step 7 would be: Provision any VM or Service.

Let me know if you have any questions.

Thanks,
Tina

Comment 6 Tina Fitzgerald 2018-01-24 15:59:43 UTC
Hi Vatsal,

Additional steps needed to validate this fix.(With quota turned off)
6a. Using the Automate Explorer, Create a writable domain.
6b. Copy the /ManageIQ/Infrastructure/VM/Provisioning/Placement/Default instance to the writable domain.
6c. Modify the newly copied "Default"instance vmware method value
from: vmware_best_least_utilized
to:  vmware_best_fit_with_scope 

I made these changes locally on your appliance in the "tina" domain and validated the fix.

(Requests 6 and 11 would have caused the invalid service template error.)

Let me know if you have any questions.

Thanks,
Tina

Comment 9 errata-xmlrpc 2018-02-28 13:13:19 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, 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-2018:0374


Note You need to log in before you can comment on or make changes to this bug.