Bug 1432578 - status 500 internal server error when invalid security group in provision request
Summary: status 500 internal server error when invalid security group in provision req...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Provisioning
Version: 5.7.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: GA
: 5.9.0
Assignee: Drew Bomhof
QA Contact: Martin Kourim
URL:
Whiteboard: api:rest:provision
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-15 17:21 UTC by Martin Kourim
Modified: 2018-03-13 15:07 UTC (History)
6 users (show)

Fixed In Version: 5.9.0.1
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-03-01 13:11:02 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:0380 0 normal SHIPPED_LIVE Moderate: Red Hat CloudForms security, bug fix, and enhancement update 2018-03-01 18:37:12 UTC

Description Martin Kourim 2017-03-15 17:21:44 UTC
Description of problem:
When creating EC2 instance with manual VPC selection, the REST API request fails with internal server error when the specified security group doesn't correspond to the selected cloud network.

{'error': {'kind': 'internal_server_error', 'klass': 'NoMethodError', 'message': "undefined method `to_a' for 65:Fixnum
             Did you mean?  to_yaml
                            to_param
                            to_c
                            to_d
                            to_r
                            to_i
                            to_f
                            to_s

Relevant log from evm.log: http://pastebin.test.redhat.com/464907


Version-Release number of selected component (if applicable):
both 5.7.1.3 and 5.8.0.4


How reproducible:
very


Steps to Reproduce:
Sample request:
POST /api/provision_requests
{
    "action": "create",
    "version": "1.1",
    "template_fields": {
        "guid": "11d44078-04ba-11e7-89eb-005056969c69"
    },
    "vm_fields": {
        "vm_name": "test-dfvsdfsdf-weox",
        "instance_type": 42,
        "request_type": "template",
        "placement_auto": false,
        "cloud_network": 1,
        "cloud_subnet": 2,
        "placement_availability_zone": 3,
        "security_groups": 65, <= this doesn't correspond to the cloud_network
        "guest_access_key_pair": 65,
        "monitoring": "basic"
    },
    "requester": {
        "user_name": "admin",
        "owner_first_name": "Administrator",
        "owner_last_name": "Administratorovich",
        "owner_email": "admin",
        "auto_approve": true
    }
}



Expected results:
graceful fail

Comment 2 Drew Bomhof 2017-06-06 13:31:46 UTC
Able to duplicate the issue using the API with the following procedure:

1. Provision to AWS using a dialog from the classic UI

2. Run the rebuild_provision_request tool (ruby tools/rebuild_provision_request.rb --request-id=<id> --console)using the provision request id created in step one.

3. Taking the output from the tool I manually modified the security_groups value to something not available on the provider.

4. Paste the changed output ( including the different security_groups value ) in the Rails console. 

require 'rest-client'; RestClient.post 'http://user:pass@localhost:3000/api/provision_requests', '{"version":"1.1","template_fields":{"guid":"6582c94e-8425-11e6-94b4-a45e60f1b905","name":"test-linux","request_type":"template"},"vm_fields":{"placement_auto":false,"placement_availability_zone":13,"cloud_network":10,"cloud_subnet":23,"security_groups":6,"number_of_vms":1,"vm_name":"db_test_provision_1","retirement":0,"retirement_warn":604800,"instance_type":136,"guest_access_key_pair":125,"monitoring":"basic","addr_mode":"dhcp"},"requester":{"owner_first_name":"d","owner_last_name":"b","owner_email":"db"},"tags":{},"additional_values":null,"ems_custom_attributes":null,"miq_custom_attributes":null}'

5. The log shows the error as referenced in the BZ description

Comment 5 CFME Bot 2017-07-11 13:32:55 UTC
New commit detected on ManageIQ/manageiq/master:
https://github.com/ManageIQ/manageiq/commit/4b29550be9d29f8bbf4e11e7ba6dc67348375425

commit 4b29550be9d29f8bbf4e11e7ba6dc67348375425
Author:     Drew Bomhof <dbomhof>
AuthorDate: Tue Jun 20 11:53:12 2017 -0400
Commit:     Drew Bomhof <dbomhof>
CommitDate: Mon Jul 10 17:18:29 2017 -0400

    Manage passing varying data types to security_groups
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1432578

 app/models/miq_request_workflow.rb                 | 24 ++++++++++++++++------
 .../miq_provision_amazon_dialogs_template.yaml     |  2 +-
 .../miq_provision_openstack_dialogs_template.yaml  |  2 +-
 spec/models/miq_request_workflow_spec.rb           |  8 ++++++++
 4 files changed, 28 insertions(+), 8 deletions(-)

Comment 6 Martin Kourim 2017-10-24 08:21:24 UTC
Verified that the exception no longer happens.

Comment 9 errata-xmlrpc 2018-03-01 13:11:02 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://access.redhat.com/errata/RHSA-2018:0380


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