Cyclical hierarchies using parent_id
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
craton |
Fix Released
|
Critical
|
git-harry |
Bug Description
Currently it is possible to set a device parent_id to its own ID or to that of a child. This prevents any further queries being made against the database.
For example:
# http GET :8080/v1/hosts/2 'X-Auth-Token:demo' 'X-Auth-User:demo' 'X-Auth-
HTTP/1.0 200 OK
Content-Length: 618
Content-Type: application/json
Date: Tue, 21 Feb 2017 14:22:29 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-
{
"active": true,
"cell_id": 1,
"created_at": "2017-02-
"device_type": "server",
"id": 2,
"ip_address": "192.168.1.5",
"links": [
{
"href": "http://
"rel": "up"
}
],
"name": "host0.
"note": null,
"parent_id": null,
"project_id": "b9f10eca-
"region_id": 1,
"updated_at": null,
"variables": {
}
}
# http PUT :8080/v1/hosts/2 'X-Auth-Token:demo' 'X-Auth-User:demo' 'X-Auth-
HTTP/1.0 200 OK
Content-Length: 399
Content-Type: application/json
Date: Tue, 21 Feb 2017 14:23:35 GMT
Server: WSGIServer/0.2 CPython/3.5.2
x-openstack-
{
"active": true,
"cell_id": 1,
"created_at": "2017-02-
"device_type": "server",
"id": 2,
"ip_address": "192.168.1.5",
"links": [
{
"href": "http://
"rel": "up"
}
],
"name": "host0.
"note": null,
"parent_id": 2,
"project_id": "b9f10eca-
"region_id": 1,
"updated_at": "2017-02-
}
# http GET :8080/v1/cells/3 'X-Auth-Token:demo' 'X-Auth-User:demo' 'X-Auth-
http: error: Request timed out (30s).
Changed in craton: | |
assignee: | Jim Baker (jimbaker) → nobody |
milestone: | none → v0.1.0 |
Changed in craton: | |
status: | New → Confirmed |
Changed in craton: | |
assignee: | nobody → git-harry (git-harry) |
Prevent by checking parent_id against the ancestors for a device; https:/ /github. com/openstack/ craton/ blob/master/ craton/ db/sqlalchemy/ models. py#L352
Should be a straightforward fix.