Bug 1146178

Summary: Can not run reports based on Cloud Provider child models that reference parent fields
Product: Red Hat CloudForms Management Engine Reporter: Dan Clarizio <dclarizi>
Component: ApplianceAssignee: Jason Frey <jfrey>
Status: CLOSED ERRATA QA Contact: Nandini Chandra <nachandr>
Severity: high Docs Contact:
Priority: medium    
Version: 5.3.0CC: bilwei, jfrey, lufu, nachandr, obarenbo, xlecauch
Target Milestone: GA   
Target Release: 5.4.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 5.4.0.0.11 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-16 12:40: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:
Attachments:
Description Flags
Simple Flavor report that causes the exception
none
Adding a new report
none
editing an existing report
none
Report result
none
Define an advance search
none
After advance search is defined none

Description Dan Clarizio 2014-09-24 16:45:04 UTC
Created attachment 940832 [details]
Simple Flavor report that causes the exception

Description of problem:
Running a report based on a Cloud Provider child model (i.e. Availability Zone, Flavor, etc) that references a parent Cloud Provider field (i.e. Cloud Provider: Name) results in an exception.

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

Steps to Reproduce:
1. Create a report based on Flavor, select Name and Cloud Provider: Name fields
2. Run the report
3. Exception screen is displayed in the UI with stack trace in the log

Actual results:
Exception

Expected results:
Report runs to completion with proper values shown

Additional info:
This is a result of the fixes for https://bugzilla.redhat.com/show_bug.cgi?id=1141319, which was added for the 5.3.0 release, but exposed this issue due to the subclassing of the EMS models for cloud.  More details can be found in the PR here as well: https://github.com/ManageIQ/manageiq/pull/585

Top of stack trace:
[----] I, [2014-09-24T16:40:52.306978 #701:f39ff8]  INFO -- : Started POST "/report/x_button/23000000000130?pressed=miq_report_run" for 127.0.0.1 at 2014-09-24 09:40:52 -0700
[----] I, [2014-09-24T16:40:52.328978 #701:f39ff8]  INFO -- : Processing by ReportController#x_button as JS
[----] I, [2014-09-24T16:40:52.329070 #701:f39ff8]  INFO -- :   Parameters: {"pressed"=>"miq_report_run", "id"=>"23000000000130"}
[----] F, [2014-09-24T16:40:52.591663 #701:f39ff8] FATAL -- : Error caught: [ActiveRecord::ConfigurationError] Association named 'ems_cloud' was not found; perhaps you misspelled it?
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:150:in `block in records_by_reflection'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:146:in `each'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:146:in `group_by'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:146:in `records_by_reflection'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:139:in `grouped_records'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:130:in `preload_one'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:109:in `preload'
/home/dclarizio/dev/manageiq/vmdb/lib/extensions/ar_virtual.rb:310:in `preload_with_virtual'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:98:in `block in run'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:98:in `each'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:98:in `run'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:117:in `block in preload_hash'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:116:in `each'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:116:in `preload_hash'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:107:in `preload'
/home/dclarizio/dev/manageiq/vmdb/lib/extensions/ar_virtual.rb:310:in `preload_with_virtual'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:98:in `block in run'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:98:in `each'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/associations/preloader.rb:98:in `run'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation.rb:181:in `block in exec_queries'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation.rb:180:in `each'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation.rb:180:in `exec_queries'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation.rb:160:in `block in to_a'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/explain.rb:33:in `logging_query_plan'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation.rb:159:in `to_a'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation/finder_methods.rb:159:in `all'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation/finder_methods.rb:105:in `find'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/relation/finder_methods.rb:101:in `find'
/home/dclarizio/.rvm/gems/ruby-1.9.3-p547/bundler/gems/rails-8cf411ee95e7/activerecord/lib/active_record/querying.rb:5:in `find'
/home/dclarizio/dev/manageiq/vmdb/app/models/rbac.rb:449:in `method_with_scope'
/home/dclarizio/dev/manageiq/vmdb/app/models/rbac.rb:252:in `find_targets_without_rbac'
/home/dclarizio/dev/manageiq/vmdb/app/models/rbac.rb:248:in `find_targets_with_rbac'
/home/dclarizio/dev/manageiq/vmdb/app/models/rbac.rb:410:in `search'
/home/dclarizio/dev/manageiq/vmdb/app/models/miq_report/generator.rb:269:in `_generate_table'

Comment 2 Jason Frey 2014-11-04 20:08:55 UTC
I've made this bug public so I can share on talk.manageiq.org.

Comment 3 CFME Bot 2015-02-19 22:15:46 UTC
New commit detected on manageiq/master:
https://github.com/ManageIQ/manageiq/commit/7c67212b7c181aae08967b1e2704dfd61960dd2e

commit 7c67212b7c181aae08967b1e2704dfd61960dd2e
Author:     Bill Wei <bilwei>
AuthorDate: Fri Feb 6 15:48:26 2015 -0500
Commit:     Bill Wei <bilwei>
CommitDate: Sat Feb 14 17:15:14 2015 -0500

    Distinguish class path and association path
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1146178

 vmdb/app/models/miq_expression.rb                  | 49 ++++++++++++----------
 vmdb/config/locales/en.yml                         |  1 +
 .../models/miq_expression/model_details_spec.rb    | 31 ++++++++++----
 3 files changed, 52 insertions(+), 29 deletions(-)

Comment 6 Bill Wei 2015-03-05 20:02:49 UTC
Created attachment 998533 [details]
Adding a new report

Selection "Provider Name" is more specific when add a new report

Comment 7 Bill Wei 2015-03-05 20:06:22 UTC
Created attachment 998536 [details]
editing an existing report

When edit the same report, the selection "Cloud Provider Name" becomes more generic "Cloud/Infrastructure Provider Name"

Comment 8 Bill Wei 2015-03-05 20:08:48 UTC
I meant selection "Cloud Provider: Name"
(In reply to Bill Wei from comment #6)
> Created attachment 998533 [details]
> Adding a new report
> 
> Selection "Provider Name" is more specific when add a new report

Comment 9 Bill Wei 2015-03-05 20:10:37 UTC
Created attachment 998538 [details]
Report result

The report runs successfully, with correct column name "Cloud Provider Name"

Comment 10 Bill Wei 2015-03-05 20:13:27 UTC
Created attachment 998540 [details]
Define an advance search

Similar problem with advance search. When define an advanced search, the selection "Cloud Provider: Name"

Comment 11 Bill Wei 2015-03-05 20:15:04 UTC
Created attachment 998541 [details]
After advance search is defined

After advance search is defined, the selection shows as "Cloud/Infrastructure Provider: Name"

Comment 12 Bill Wei 2015-03-05 20:17:32 UTC
With the fix, the report runs correctly without an issue. There are some minor UI displaying issues. Attachments were created above.

Comment 14 Nandini Chandra 2015-04-11 02:44:56 UTC
Verified in 5.4.0.0.11

Comment 16 errata-xmlrpc 2015-06-16 12:40:14 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://rhn.redhat.com/errata/RHBA-2015-1100.html