Project

General

Profile

Actions

Bug #38474

open

Simultaneous POST to /api/hostgroup creates multiple Hostgroups with same name

Added by Pablo Fernández Rodríguez 3 days ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
API
Target version:
-
Difficulty:
Triaged:
No
Fixed in Releases:
Found in Releases:

Description

Description of problem:
Do two POST requests to create same Hostgroup name at same time creates a duplicated Hostgroup. 

How reproducible:
Always

Is this issue a regression from an earlier version:
No
 

Steps to Reproduce:
Execute next curl at same time in two terminals

curl -X POST https://pafernan-6179sat.6179.pafernan.lan/api/hostgroups --user 'admin:redhat' -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{ "hostgroup":{ "name": "test", "environment_id": 1, "architecture_id": 1, "domain_id": 1, "subnet_id": 1, "operatingsystem_id": 1, "medium_id": 6, "ptable_id": 7, "location_id": 1, "organization_id": 1 }}'

Actual behavior:
HostGroup "test" is created twice

Expected behavior:
One of the requests should fail as it already does if we retry:

{
  "error": {"id":null,"errors":{"name":["has already been taken"]},"full_messages":["Name has already been taken"]}
}

No data to display

Actions

Also available in: Atom PDF