Bug 1531914

Summary: Quota fails when an active Service request contains an Invalid service_template.
Product: Red Hat CloudForms Management Engine Reporter: Saif Ali <saali>
Component: AutomateAssignee: Tina Fitzgerald <tfitzger>
Status: CLOSED CURRENTRELEASE QA Contact: Ganesh Hubale <ghubale>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.8.0CC: akarol, cpelland, ghubale, jocarter, mkanoor, obarenbo, rovalent, saali, simaishi, tfitzger, vparekh
Target Milestone: GAKeywords: TestOnly
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.10.0.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1533217 1534589 (view as bug list) Environment:
Last Closed: 2018-06-21 20:46:14 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: 1533217, 1534589    
Attachments:
Description Flags
active_service_request.rb none

Description Saif Ali 2018-01-06 16:52:27 UTC
Description of problem:
Provisioning request fail with quota error

[----] 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]) /var/www/miq/vmdb/app/models/mixins/miq_provision_quota_mixin.rb:324:in `service_quota_values'
/var/www/miq/vmdb/app/models/mixins/miq_provision_quota_mixin.rb:351:in `block in quota_provision_stats'
/opt/rh/cfme-gemset/gems/activerecord-5.0.3/lib/active_record/relation/delegation.rb:40:in `each'
/opt/rh/cfme-gemset/gems/activerecord-5.0.3/lib/active_record/relation/delegation.rb:40:in `each'
/var/www/miq/vmdb/app/models/mixins/miq_provision_quota_mixin.rb:350:in `quota_provision_stats'
/var/www/miq/vmdb/app/models/mixins/miq_provision_quota_mixin.rb:84:in `quota_active_provisions'
/var/www/miq/vmdb/app/models/mixins/miq_provision_quota_mixin.rb:12:in `check_quota'
/var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:266:in `public_send'
/var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:266:in `block in object_send'
/var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:285:in `ar_method'
/var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:295:in `ar_method'
/var/www/miq/vmdb/lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service_model_base.rb:264:in `object_send'
/var/www/miq/vmdb/lib/miq_automation_engine/service_models/mixins/miq_ae_service_miq_provision_mixin.rb:42:in `check_quota'
/opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1624:in `perform_without_block'
/opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1584:in `perform'
/opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1657:in `block (2 levels) in main_loop'
/opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1653:in `loop'
/opt/rh/rh-ruby23/root/usr/share/ruby/drb/drb.rb:1653:in `block in main_loop'


Version-Release number of selected component (if applicable):
5.8.2.3

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 3 Greg McCullough 2018-01-06 20:04:55 UTC
Created attachment 1377944 [details]
active_service_request.rb

Please run the attached script from an appliance console using "bin/rails r <script_name>"

The output should display Active Service Template Provision Requests and specifically invalid ones that no longer have a relationship to the service_template.

These invalid requests are the ones causing the issue and should likely be deleted.

Comment 7 Saif Ali 2018-01-08 16:15:44 UTC
Greg, 
I checked and there is no automate role defined for that zone.

Comment 9 CFME Bot 2018-01-09 20:30:53 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/0d6e97436173326912dd8fdd6e121bf8fed9ca53

commit 0d6e97436173326912dd8fdd6e121bf8fed9ca53
Author:     Tina Fitzgerald <tfitzger>
AuthorDate: Mon Jan 8 14:33:58 2018 -0500
Commit:     Tina Fitzgerald <tfitzger>
CommitDate: Mon Jan 8 14:33:58 2018 -0500

    Prevent quota error for invalid service_template.
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1531914

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