500 on resource deletes from foreign key constraint error

Bug #1668081 reported by Thomas Maddox
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
craton
New
Undecided
Unassigned

Bug Description

Currently when one tries to delete a resource that still has associated children, we get a 500 back from the API:

$ craton region-delete 1
ERROR: Internal Server Error (HTTP 500) (Request-ID: req-9eab3920-8691-4843-b6a6-178c2be3621e)

Error:
2017-02-26 16:52:43.514 193 ERROR craton.api.v1.resources.inventory.regions [req-9eab3920-8691-4843-b6a6-178c2be3621e - - - - -] Error during RegionsById.delete: (pymysql.err.IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`craton`.`cells`, CONSTRAINT `cells_ibfk_3` FOREIGN KEY (`region_id`) REFERENCES `regions` (`id`))') [SQL: 'DELETE FROM regions WHERE regions.project_id = %(project_id_1)s AND regions.id = %(id_1)s'] [parameters: {'project_id_1': 'b9f10eca66ac4c279c139d01e65f96b4', 'id_1': '1'}]

It seems this was addressed already for hosts (https://bugs.launchpad.net/craton/+bug/1657905), but not for the rest of the resources.

Perhaps, for the higher-level resources, we should err on the side of messaging about needing to delete children rather than just blowing away a potentially large amount of data by accident?

Revision history for this message
Jim Baker (jimbaker) wrote :
Revision history for this message
Jim Baker (jimbaker) wrote :

Therefore it suggests some additional testing for the Alembic script change, specifically functional tests. This can be done within that change, or in a fast follow.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.