Bug 1308563 - Adding a host with a name that is already in use returns a Bad Request (code 400)
Adding a host with a name that is already in use returns a Bad Request (code ...
Status: CLOSED CURRENTRELEASE
Product: ovirt-engine
Classification: oVirt
Component: RestAPI (Show other bugs)
4.0.0
Unspecified Unspecified
low Severity low (vote)
: ovirt-4.0.0-beta
: 4.0.0
Assigned To: Boriso
Petr Kubica
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-15 09:04 EST by Idan Shaby
Modified: 2016-07-05 03:52 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-07-05 03:52:27 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: Infra
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
rule-engine: ovirt‑4.0.0+
rule-engine: planning_ack+
juan.hernandez: devel_ack+
pstehlik: testing_ack+


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
oVirt gerrit 57192 master MERGED restapi: Fixed HTTP error code for host name duplication error. 2016-05-09 06:41 EDT

  None (edit)
Description Idan Shaby 2016-02-15 09:04:11 EST
Description of problem:
Adding a host with a name that is already in use returns a bad request (code 400), while doing the same with a Data Center returns a conflict (code 409).

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

How reproducible:
100%

Steps to Reproduce:
1. Add a host through the REST-API.
2. Add the same host again.
3.

Actual results:
Bad request (code 400) with the message: "Cannot add Host. The Host name is already in use, please choose a unique name and try again."

Expected results:
We should get a conflict, not a bad request.

Additional info:
Adding a data center with a name that is already in use returns a conflict (code 409) with the message: "Cannot create Data Center. The Data Center name is already in use."
Comment 1 Juan Hernández 2016-02-24 07:25:45 EST
The API translates the error messages returned by the backend into HTTP codes according to the value returned by the ErrorMessage.getErrorType() message. The error returned by the backend when the name of the host is already in use is ACTION_TYPE_FAILED_NAME_ALREADY_USED, and the corresponding ErrorType is BAD_PARAMETERS, not CONFLICT. Not sure why it isn't CONFLICT. The change is simple, but it may have a backwards compatibility effect in existing clients, so I think it is better to not change it in the 3.6 branch.

Ori, do you know why this error type isn't classified as CONFLICT?
Comment 2 Sandro Bonazzola 2016-05-02 05:59:39 EDT
Moving from 4.0 alpha to 4.0 beta since 4.0 alpha has been already released and bug is not ON_QA.
Comment 3 Petr Kubica 2016-06-07 08:43:34 EDT
Verified in 
ovirt-engine-restapi-4.1.0-0.0.master.20160606111312.gitc7af584.el7.centos.noarch

Response: 409 Conflict: Cannot add Host. Host with the same address already exists.
Comment 4 Sandro Bonazzola 2016-07-05 03:52:27 EDT
oVirt 4.0.0 has been released, closing current release.

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