Bug 1449053

Summary: UI: Security Groups show fails with comparison of Array with Array error
Product: Red Hat CloudForms Management Engine Reporter: Gilles Dubreuil <gdubreui>
Component: UI - OPSAssignee: Harpreet Kataria <hkataria>
Status: CLOSED CURRENTRELEASE QA Contact: Ido Ovadia <iovadia>
Severity: high Docs Contact:
Priority: high    
Version: 5.8.0CC: cpelland, hkataria, iovadia, jhardy, mpovolny, obarenbo
Target Milestone: GAKeywords: TestOnly
Target Release: 5.9.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: ui:error
Fixed In Version: 5.9.0.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1449365 (view as bug list) Environment:
Last Closed: 2018-03-06 14:52:24 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: Bug
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: Openstack Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1449365    

Description Gilles Dubreuil 2017-05-09 07:23:32 UTC
Display details of a security groups generate an exception when 2 rules overlap.

Versions:
This is happening with current master branch but is likely to happen with 5.7 - to be confirmed.

Steps to Reproduce:
1. Create a security group
$ neutron security-group-create test2

2. Add a rule to the security group:
$ neutron security-group-rule-create --direction egress --ethertype IPv4 --protocol tcp --remote-ip-prefix 192.168.10.1/32 --port-range-min 88 --port-range-max 88 1d8f66dc-e8bb-4c77-b1b9-db5cde0a7dda

3. Add a rule that overlap previous rule (here port is specified):
$ neutron security-group-rule-create --direction egress --ethertype IPv4 --protocol tcp --remote-ip-prefix 192.168.10.1/32 1d8f66dc-e8bb-4c77-b1b9-db5cde0a7dda

4. Use the UI to show the security group:
Network -> Security Groups -> Select the created security group in the list.

Actual results:
The GUI display the following error:
"comparison of Array with Array failed [security_group/show]" 


Additional info:
Extract from rails log file:
--------------------------------------------------------------------------------
[----] D, [2017-05-09T03:16:09.207462 #30871:3f8a6a6c25f8] DEBUG -- :   FirewallRule Exists (0.4ms)  SELECT  1 AS one FROM "firewall_rul
es" WHERE "firewall_rules"."resource_id" = $1 AND "firewall_rules"."resource_type" = $2 LIMIT $3  [["resource_id", 2], ["resource_type",
 "SecurityGroup"], ["LIMIT", 1]]
[----] D, [2017-05-09T03:16:09.209735 #30871:3f8a6a6c25f8] DEBUG -- :   FirewallRule Load (0.3ms)  SELECT "firewall_rules".* FROM "firew
all_rules" WHERE "firewall_rules"."resource_id" = $1 AND "firewall_rules"."resource_type" = $2  [["resource_id", 2], ["resource_type", "
SecurityGroup"]]
[----] D, [2017-05-09T03:16:09.228601 #30871:3f8a6a6c25f8] DEBUG -- :   FirewallRule Inst Including Associations (18.6ms - 2rows)
[----] I, [2017-05-09T03:16:09.233374 #30871:3f8a6a6c25f8]  INFO -- :   Rendered /home/gildub/manageiq-ui-classic/app/views/layouts/_tex
tual_groups_raw.html.haml (3176.5ms)
[----] I, [2017-05-09T03:16:09.233508 #30871:3f8a6a6c25f8]  INFO -- :   Rendered /home/gildub/manageiq-ui-classic/app/views/layouts/_tex
tual_groups_generic.html.haml (3184.3ms)
[----] I, [2017-05-09T03:16:09.233928 #30871:3f8a6a6c25f8]  INFO -- :   Rendered /home/gildub/manageiq-ui-classic/app/views/security_gro
up/show.html.haml within layouts/application (3193.6ms)
[----] F, [2017-05-09T03:16:09.234221 #30871:3f8a6a6c25f8] FATAL -- : Error caught: [ActionView::Template::Error] comparison of Array wi
th Array failed
/home/gildub/manageiq-ui-classic/app/helpers/security_group_helper/textual_summary.rb:32:in `sort'
/home/gildub/manageiq-ui-classic/app/helpers/security_group_helper/textual_summary.rb:32:in `textual_group_firewall'
/home/gildub/manageiq-ui-classic/app/helpers/textual_summary_helper.rb:43:in `textual_group_render_options'
--------------------------------------------------------------------------------

Comment 2 Harpreet Kataria 2017-05-09 16:11:35 UTC
https://github.com/ManageIQ/manageiq-ui-classic/pull/1318

Comment 3 CFME Bot 2017-05-09 16:38:47 UTC
New commit detected on ManageIQ/manageiq-ui-classic/master:
https://github.com/ManageIQ/manageiq-ui-classic/commit/f2d066f57d138b8ecb9058776cf35bc8ce15e6f7

commit f2d066f57d138b8ecb9058776cf35bc8ce15e6f7
Author:     Harpreet Kataria <hkataria>
AuthorDate: Tue May 9 12:09:14 2017 -0400
Commit:     Harpreet Kataria <hkataria>
CommitDate: Tue May 9 12:09:14 2017 -0400

    Added to_i to port & end_port attributes
    
    Added to_i to 'port' & 'end_port' attributes, to prevent comparison of Array with Array error when there is no value provided for port or end_port fields.
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1449053

 app/helpers/security_group_helper/textual_summary.rb    |  4 ++--
 .../security_group_helper/textual_summary_spec.rb       | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 2 deletions(-)
 create mode 100644 spec/helpers/security_group_helper/textual_summary_spec.rb

Comment 5 Gilles Dubreuil 2017-05-11 00:42:30 UTC
I tested and confirm that using the aforementioned patch, a security group including overlapped rules can now be displayed.

Comment 6 Ido Ovadia 2017-12-21 14:08:00 UTC
Verified
========
5.9.0.14