Bug 1541036

Summary: Improving the error message of provisioning a VM via rest api with wrong vlan value
Product: Red Hat CloudForms Management Engine Reporter: Martin Kourim <mkourim>
Component: APIAssignee: Alona Kaplan <alkaplan>
Status: CLOSED CURRENTRELEASE QA Contact: Radim Hrazdil <rhrazdil>
Severity: high Docs Contact:
Priority: low    
Version: 5.9.0CC: alkaplan, brant.evans, cpelland, dajohnso, danken, istein, jprause, jzmeskal, mperina, obarenbo, simaishi, smallamp, tuado
Target Milestone: GAKeywords: TestOnly, ZStream
Target Release: 5.10.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: api:rest:provisioning
Fixed In Version: 5.10.0.0 Doc Type: Bug Fix
Doc Text:
The examples part in the documentation should be updated. (https://access.redhat.com/documentation/en-us/red_hat_cloudforms/4.6/html/red_hat_cloudforms_rest_api/chap_examples) The 'vlan' field in the provision request should contain the id of the vnic profile the user wants to assign to the vnic. POST /api/provision_requests { .. "vm_fields" : { .. "vlan" : "9da9fcab-6d8f-4319-a3b8-571c4cc1bffd" }, .. }
Story Points: ---
Clone Of:
: 1578393 (view as bug list) Environment:
Last Closed: 2018-11-20 19:30:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: RHEVM Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1578393    

Description Martin Kourim 2018-02-01 15:03:12 UTC
Created attachment 1389546 [details]
api.log

Description of problem:
When creating provision request on RHEV provider the REST request fails with
{
    "error": {
        "kind": "internal_server_error",
        "message": "Provision failed for the following reasons:\n'Network/Network' is required",
        "klass": "RuntimeError"
    }
}
status code: 500 Internal Server Error


Version-Release number of selected component (if applicable):
5.9.0.18, 5.9.0.19
Checked that the identical request works as expected on 5.9.0.16


How reproducible:
100%


Steps to Reproduce:

POST /api/provision_requests
{"additional_values": {"request_id": "1001"},
 "ems_custom_attributes": {},
 "miq_custom_attributes": {},
 "requester": {"auto_approve": false,
  "owner_email": "jdoe",
  "owner_first_name": "John",
  "owner_last_name": "Doe",
  "user_name": "admin"},
 "tags": {"cc": "001", "network_location": "Internal"},
 "template_fields": {"guid": "<template_guid>"},
 "version": "1.1",
 "vm_fields": {"number_of_cpus": 1,
  "provision_type": "native_clone",
  "vlan": "ovirtmgmt",
  "vm_memory": "2048",
  "vm_name": "test_rest_prov_B2qNFMMOuF"}}

Comment 4 Alona Kaplan 2018-02-06 12:45:13 UTC
The vlan field should contain the profile_id (taken from ovirt), '<Empty>' or '<Template>' values.
Please refer to https://bugzilla.redhat.com/1449157 doc text for more details.


I'm changing the bug to improving the error message in case of wrong value passed to the vlan field.
Removing the regression keyword and changing the priority.

Comment 5 Jan Zmeskal 2018-02-07 10:57:56 UTC
I believe as part of resolution of this bug, documentation should be changed. Firstly see 2.7.4 here:

https://access.redhat.com/documentation/en-us/red_hat_cloudforms/4.6-beta/html/red_hat_cloudforms_rest_api/chap_reference_guide#provision-requests-attribute-groups

Description of "vlan" attribute is "vLAN" while in fact it is vNIC profile ID now. 

Also attribute "vlan" has invalid value in all of the examples here:

https://access.redhat.com/documentation/en-us/red_hat_cloudforms/4.6-beta/html/red_hat_cloudforms_rest_api/chap_examples#sect_provisioning_requests

Comment 6 Dan Kenigsberg 2018-02-18 09:03:04 UTC
The bug is not a TestBlocker, nor a regression. I'm removing its blocker flag.

Comment 7 Alona Kaplan 2018-04-22 07:06:23 UTC
*** Bug 1569247 has been marked as a duplicate of this bug. ***

Comment 15 Satoe Imaishi 2018-05-30 20:11:30 UTC
https://github.com/ManageIQ/manageiq/pull/17495

Comment 16 Martin Kourim 2018-07-11 09:44:59 UTC
When wrong value is passed to the vlan field the error message is now
{
"error":{
"kind": "internal_server_error",
"message": "Provision failed for the following reasons:\n'Network/Virtual NIC Profile ID or Profile Name (Network Name)' is required",
"klass": "RuntimeError"
}
}

While the error is expected and the message makes sense, I'm wondering if "internal server error" with status code 500 is what we expect. In my opinion it should be status code 400 and "kind": "bad_request" as is the case for other requests with wrong values.

Comment 17 Radim Hrazdil 2018-09-18 09:59:40 UTC
I tend to agree with Martin's comment above. Please revise. Moving to ON_DEV.

Comment 19 Martin Perina 2018-10-19 14:29:14 UTC
Removing blocker flag, this bug is not a regression nor blocker, the behavior just changed between RHV versions.

Comment 20 Sudhir Mallamprabhakara 2018-11-20 19:30:18 UTC
Based of BZ1578393