gophercloud / utils

Apache License 2.0
20 stars 55 forks source link

Make the deletion of network resources more robust #119

Closed johscheuer closed 4 years ago

johscheuer commented 4 years ago

During the cleanup of a project I ran in several challenges:

Expected HTTP response code [] when accessing [DELETE https://mycloud/v2.0/floatingips/0083695c-d17b-4ee7-8610-330d25bde798], but got 409 instead
{"NeutronError": {"type": "FipInUseByPortForwarding", "message": "Floating IP 0083695c-d17b-4ee7-8610-330d25bde798 in use by Port Forwarding resources.", "detail": ""}}
Error deleting floating IP: 0083695c-d17b-4ee7-8610-330d25bde798 from project: 7d44d6117b29422382837433bd266141

and

{"NeutronError": {"type": "ServicePortInUse", "message": "Port 184a0435-4b69-4307-9e53-0eb7073ad9f7 cannot be deleted directly via the port API: has device owner network:ha_router_replicated_interface.", "detail": ""}}

and

Expected HTTP response code [] when accessing [DELETE https://mycloud/v2.0/routers/2cb975a9-aebd-4c18-86f9-e56adda6cb9b], but got 409 instead
{"NeutronError": {"type": "RouterInUse", "message": "Router 2cb975a9-aebd-4c18-86f9-e56adda6cb9b still has ports", "detail": ""}}
Error deleting router: router_1 from project: 7d44d6117b29422382837433bd266141

and

Expected HTTP response code [200] when accessing [PUT https://mycloud/v2.0/routers/dc820e2f-afaf-476a-9337-b3bb86146ce7/remove_router_interface], but got 409 instead
{"NeutronError": {"type": "RouterInterfaceInUseByRoute", "message": "Router interface for subnet 09d9e3b8-e06e-4af7-bcf7-870e483f4372 on router dc820e2f-afaf-476a-9337-b3bb86146ce7 cannot be deleted, as it is required by one or more routes.", "detail": ""}}
Expected HTTP response code [] when accessing [DELETE https://mycloud/v2.0/routers/dc820e2f-afaf-476a-9337-b3bb86146ce7], but got 409 instead
{"NeutronError": {"type": "RouterInUse", "message": "Router dc820e2f-afaf-476a-9337-b3bb86146ce7 still has ports", "detail": ""}}
Error deleting router: idcp_router from project: 3cdd2eab26ff423f873a5ec60d26e146

This PR make the purge part a little bit more robust in order to cleanup dependencies.