Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1534589 - Quota fails when an active Service request contains an Invalid service_template.
Quota fails when an active Service request contains an Invalid service_template.
Status: CLOSED ERRATA
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate (Show other bugs)
5.8.0
Unspecified Unspecified
urgent Severity urgent
: GA
: 5.8.3
Assigned To: Tina Fitzgerald
Vatsal Parekh
: ZStream
Depends On: 1531914
Blocks:
  Show dependency treegraph
 
Reported: 2018-01-15 09:15 EST by Satoe Imaishi
Modified: 2018-02-28 08:13 EST (History)
11 users (show)

See Also:
Fixed In Version: 5.8.3.1
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1531914
Environment:
Last Closed: 2018-02-28 08:13:19 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3312341 None None None 2018-01-15 09:15 EST
Red Hat Product Errata RHSA-2018:0374 normal SHIPPED_LIVE Important: Red Hat CloudForms security, bug fix, and enhancement update 2018-02-28 13:04:37 EST

  None (edit)
Comment 2 CFME Bot 2018-01-15 09:21:30 EST
New commit detected on ManageIQ/manageiq/fine:
https://github.com/ManageIQ/manageiq/commit/7de622587cc1a162178b6ccf9d78f2188522d3f9

commit 7de622587cc1a162178b6ccf9d78f2188522d3f9
Author:     Greg McCullough <gmccullo@redhat.com>
AuthorDate: Tue Jan 9 15:30:37 2018 -0500
Commit:     Satoe Imaishi <simaishi@redhat.com>
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 08:17:18 EST
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 10:59:43 EST
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 08:13:19 EST
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.