Bug 1343454 - Unexpected error when sorting "instances" column in network manager security groups
Summary: Unexpected error when sorting "instances" column in network manager security ...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: UI - OPS
Version: 5.6.0
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: GA
: 5.7.0
Assignee: Keenan Brock
QA Contact: Pavol Kotvan
URL:
Whiteboard: ui:error:network
Depends On:
Blocks: 1347005 1347695
TreeView+ depends on / blocked
 
Reported: 2016-06-07 11:25 UTC by Aziza Karol
Modified: 2017-01-12 04:46 UTC (History)
8 users (show)

Fixed In Version: 5.7.0.0
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1347005 1347695 (view as bug list)
Environment:
Last Closed: 2017-01-11 20:23:07 UTC
Category: Bug
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
error (154.72 KB, image/png)
2016-06-07 11:25 UTC, Aziza Karol
no flags Details

Description Aziza Karol 2016-06-07 11:25:15 UTC
Created attachment 1165580 [details]
error

Description of problem:


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

How reproducible:
100%

Steps to Reproduce:
1.Navigate to networks->providers
2.In network manager summary page click on "security groups" in Relationships
3.Try sorting the "instances" column in all security groups

Actual results:
Error caught: [ActiveRecord::StatementInvalid] PG::UndefinedColumn: ERROR:  column vms.security_group_id does not exist displayed in UI .see attached screenshot.


Expected results:
sorting should work

Additional info:
production.log
[----] I, [2016-06-07T06:58:28.153490 #3016:b861a4]  INFO -- : Started POST "/ems_network/show/3?sortby=3&display=security_groups" for 127.0.0.1 at 2016-06-07 06:58:28 -0400
[----] I, [2016-06-07T06:58:28.155051 #3016:b861a4]  INFO -- : Processing by EmsNetworkController#show as JS
[----] I, [2016-06-07T06:58:28.155149 #3016:b861a4]  INFO -- :   Parameters: {"sortby"=>"3", "display"=>"security_groups", "id"=>"3"}
[----] F, [2016-06-07T06:58:28.430715 #3016:b861a4] FATAL -- : Error caught: [ActiveRecord::StatementInvalid] PG::UndefinedColumn: ERROR:  column vms.security_group_id does not exist
LINE 1: ...OUNT(*) FROM "vms" WHERE "security_groups"."id" = "vms"."sec...
                                                             ^
: SELECT  "security_groups"."id" AS t0_r0, "security_groups"."name" AS t0_r1, "security_groups"."description" AS t0_r2, "security_groups"."type" AS t0_r3, "security_groups"."ems_id" AS t0_r4, "security_groups"."ems_ref" AS t0_r5, "security_groups"."cloud_network_id" AS t0_r6, "security_groups"."cloud_tenant_id" AS t0_r7, "security_groups"."orchestration_stack_id" AS t0_r8, "security_groups"."network_group_id" AS t0_r9, "ext_management_systems"."id" AS t1_r0, "ext_management_systems"."name" AS t1_r1, "ext_management_systems"."created_on" AS t1_r2, "ext_management_systems"."updated_on" AS t1_r3, "ext_management_systems"."guid" AS t1_r4, "ext_management_systems"."zone_id" AS t1_r5, "ext_management_systems"."type" AS t1_r6, "ext_management_systems"."api_version" AS t1_r7, "ext_management_systems"."uid_ems" AS t1_r8, "ext_management_systems"."host_default_vnc_port_start" AS t1_r9, "ext_management_systems"."host_default_vnc_port_end" AS t1_r10, "ext_management_systems"."provider_region" AS t1_r11, "ext_management_systems"."last_refresh_error" AS t1_r12, "ext_management_systems"."last_refresh_date" AS t1_r13, "ext_management_systems"."provider_id" AS t1_r14, "ext_management_systems"."realm" AS t1_r15, "ext_management_systems"."tenant_id" AS t1_r16, "ext_management_systems"."project" AS t1_r17, "ext_management_systems"."parent_ems_id" AS t1_r18, "ext_management_systems"."subscription" AS t1_r19 FROM "security_groups" LEFT OUTER JOIN "ext_management_systems" ON "ext_management_systems"."id" = "security_groups"."ems_id" AND "ext_management_systems"."type" IN ('ManageIQ::Providers::BaseManager', 'ManageIQ::Providers::ContainerManager', 'ManageIQ::Providers::CloudManager', 'ManageIQ::Providers::InfraManager', 'ManageIQ::Providers::MiddlewareManager', 'ManageIQ::Providers::NetworkManager', 'ManageIQ::Providers::Kubernetes::ContainerManager', 'ManageIQ::Providers::Atomic::ContainerManager', 'ManageIQ::Providers::AtomicEnterprise::ContainerManager', 'ManageIQ::Providers::Openshift::ContainerManager', 'ManageIQ::Providers::OpenshiftEnterprise::ContainerManager', 'ManageIQ::Providers::Azure::CloudManager', 'ManageIQ::Providers::Google::CloudManager', 'ManageIQ::Providers::Amazon::CloudManager', 'ManageIQ::Providers::Openstack::CloudManager', 'ManageIQ::Providers::Microsoft::InfraManager', 'ManageIQ::Providers::Redhat::InfraManager', 'ManageIQ::Providers::Vmware::InfraManager', 'ManageIQ::Providers::Openstack::InfraManager', 'ManageIQ::Providers::Hawkular::MiddlewareManager', 'ManageIQ::Providers::Azure::NetworkManager', 'ManageIQ::Providers::Openstack::NetworkManager', 'ManageIQ::Providers::Amazon::NetworkManager') WHERE (security_groups.id IN (1,4,5,7,2,3,6,8)) ORDER BY ((SELECT COUNT(*) FROM "vms" WHERE "security_groups"."id" = "vms"."security_group_id")) ASC LIMIT $1 OFFSET $2
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `async_exec'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `block in exec_no_cache'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:566:in `block in log'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:560:in `log'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `exec_no_cache'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb:587:in `execute_and_clear'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/postgresql/database_statements.rb:103:in `exec_query'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:373:in `select'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:41:in `select_all'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `block in select_all'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:83:in `cache_sql'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:68:in `select_all'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/relation/finder_methods.rb:389:in `find_with_associations'
/var/www/miq/vmdb/lib/extensions/ar_virtual.rb:407:in `find_with_associations'
/var/www/miq/vmdb/lib/extensions/ar_virtual.rb:409:in `find_with_associations'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/relation.rb:699:in `exec_queries'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/relation.rb:580:in `load'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/relation.rb:260:in `records'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/relation.rb:256:in `to_a'
/var/www/miq/vmdb/app/models/miq_report/generator.rb:350:in `build_table'
/var/www/miq/vmdb/app/models/miq_report/search.rb:114:in `paged_view_search'
/var/www/miq/vmdb/app/controllers/application_controller.rb:1590:in `get_view'
/var/www/miq/vmdb/app/controllers/ems_common.rb:118:in `view_setup_helper'
/var/www/miq/vmdb/app/controllers/ems_common.rb:73:in `show'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/abstract_controller/base.rb:181:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal/rendering.rb:30:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/abstract_controller/callbacks.rb:20:in `block in process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:126:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:126:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:506:in `block (2 levels) in compile'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:455:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:455:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:101:in `__run_callbacks__'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:750:in `_run_process_action_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:90:in `run_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/abstract_controller/callbacks.rb:19:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal/rescue.rb:20:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/notifications.rb:164:in `block in instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/notifications.rb:164:in `instrument'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal/params_wrapper.rb:248:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activerecord/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/abstract_controller/base.rb:126:in `process'
/opt/rh/cfme-gemset/gems/actionview-5.0.0.rc1/lib/action_view/rendering.rb:30:in `process'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal.rb:190:in `dispatch'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_controller/metal.rb:262:in `dispatch'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/routing/route_set.rb:32:in `serve'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/journey/router.rb:39:in `block in serve'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/journey/router.rb:26:in `each'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/journey/router.rb:26:in `serve'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/routing/route_set.rb:725:in `call'
/opt/rh/cfme-gemset/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:186:in `call!'
/opt/rh/cfme-gemset/gems/omniauth-1.3.1/lib/omniauth/strategy.rb:164:in `call'
/opt/rh/cfme-gemset/gems/omniauth-1.3.1/lib/omniauth/builder.rb:63:in `call'
/opt/rh/cfme-gemset/gems/secure_headers-3.0.3/lib/secure_headers/middleware.rb:10:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/etag.rb:25:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/conditional_get.rb:38:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/head.rb:12:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/session/abstract/id.rb:222:in `context'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/session/abstract/id.rb:216:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/cookies.rb:613:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:97:in `__run_callbacks__'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/callbacks.rb:90:in `run_callbacks'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/callbacks.rb:36:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
/opt/rh/cfme-gemset/gems/railties-5.0.0.rc1/lib/rails/rack/logger.rb:36:in `call_app'
/opt/rh/cfme-gemset/gems/railties-5.0.0.rc1/lib/rails/rack/logger.rb:26:in `call'
/opt/rh/cfme-gemset/gems/request_store-1.3.1/lib/request_store/middleware.rb:9:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/request_id.rb:24:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/method_override.rb:22:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/runtime.rb:22:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/activesupport/lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
/opt/rh/cfme-gemset/bundler/gems/rails-41f47090a7cd/actionpack/lib/action_dispatch/middleware/executor.rb:12:in `call'
/opt/rh/cfme-gemset/gems/rack-2.0.0.rc1/lib/rack/sendfile.rb:111:in `call'
/opt/rh/cfme-gemset/gems/railties-5.0.0.rc1/lib/rails/engine.rb:522:in `call'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/puma-3.3.0/lib/puma/configuration.rb:224:in `call'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/puma-3.3.0/lib/puma/server.rb:561:in `handle_request'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/puma-3.3.0/lib/puma/server.rb:406:in `process_client'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/puma-3.3.0/lib/puma/server.rb:271:in `block in run'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/puma-3.3.0/lib/puma/thread_pool.rb:111:in `call'
/opt/rh/rh-ruby22/root/usr/share/gems/gems/puma-3.3.0/lib/puma/thread_pool.rb:111:in `block in spawn_thread'
/opt/rh/cfme-gemset/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `call'
/opt/rh/cfme-gemset/gems/logging-1.8.2/lib/logging/diagnostic_context.rb:323:in `block in create_with_logging_context'
[----] I, [2016-06-07T06:58:28.453208 #3016:b861a4]  INFO -- :   Rendered layouts/_exception_contents.html.haml (7.4ms)
[----] I, [2016-06-07T06:58:28.454418 #3016:b861a4]  INFO -- : Completed 200 OK in 299ms (Views: 22.7ms | ActiveRecord: 0.0ms)

Comment 4 Ladislav Smola 2016-06-16 11:12:04 UTC
Hm, we started to generate incorrect order by

ORDER BY ((SELECT COUNT(*) FROM "vms" WHERE "cloud_subnets"."id" = "vms"."device_id")) 

This query is wrong and is even using non existent columns.

---

@Keenan do you know if there were some changes of how we do 'order by' of the tables? This is order by using virtual_column total_vms, e.g. on SecurityGroup or CloudSubnet model. It was working nicely before, but now, all of them are broken.

Comment 5 Keenan Brock 2016-06-16 15:03:34 UTC
This is mine.

it may be yaml based, but think it is around the count(*) in rbac doing the wrong thing.

Comment 8 CFME Bot 2016-06-23 17:07:03 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/69971c402e5233f12a3c2ab75e0bad95cf62e7f7

commit 69971c402e5233f12a3c2ab75e0bad95cf62e7f7
Author:     Keenan Brock <kbrock>
AuthorDate: Thu Jun 16 15:50:26 2016 -0400
Commit:     Keenan Brock <kbrock>
CommitDate: Thu Jun 16 22:03:22 2016 -0400

    Only define virtual totals for simple has_many
    
    The arel has only been build out for has_many (non :through)
    So only add the arel for that one use case.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1343454

 app/models/mixins/virtual_total_mixin.rb | 13 ++++++++++---
 app/models/security_group.rb             |  2 +-
 spec/models/security_group_spec.rb       | 12 ++++++++++++
 3 files changed, 23 insertions(+), 4 deletions(-)

Comment 9 Keenan Brock 2016-06-24 16:52:57 UTC
merged on master.
waiting backporting to darga


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