Comment 0 for bug 1104337

Revision history for this message
Terry Wilson (otherwiseguy) wrote :

When adding a subnet to a router via router-interface-add, it is possible to delete the subnet without removing the interface. This leaves a port behind that cannot be deleted because it is part of a router, and a router that cannot be deleted because it has an active port. It is possible to delete the port via running a network-delete, but one shouldn't have to delete the entire network just to fix the issue.

I'm attaching a patch that deletes ports marked as AUTO_DELETE_PORT_OWNERS when deleting the subnet (the same thing that happens if we cascade deleting by deleting a network) instead of just deleting the IPAllocation.

Example of issue:
[terry@f17-devstack1 quantum]$ quantum net-create net1
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| id | ee4e9eae-f51d-442d-84c0-d81b6e1ba69e |
| name | net1 |
| provider:network_type | vlan |
| provider:physical_network | physnet1 |
| provider:segmentation_id | 1 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 2e3986dd9ea643f4949223283299ddec |
+---------------------------+--------------------------------------+
[terry@f17-devstack1 quantum]$ quantum subnet-create net1 10.10.10.0/24 --name subnet1
Created a new subnet:
+------------------+------------------------------------------------+
| Field | Value |
+------------------+------------------------------------------------+
| allocation_pools | {"start": "10.10.10.2", "end": "10.10.10.254"} |
| cidr | 10.10.10.0/24 |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 10.10.10.1 |
| host_routes | |
| id | 02eb6689-04b0-4617-8bf9-10fddc2fa591 |
| ip_version | 4 |
| name | subnet1 |
| network_id | ee4e9eae-f51d-442d-84c0-d81b6e1ba69e |
| tenant_id | 2e3986dd9ea643f4949223283299ddec |
+------------------+------------------------------------------------+
[terry@f17-devstack1 quantum]$ quantum router-create router1
Created a new router:
+-----------------------+--------------------------------------+
| Field | Value |
+-----------------------+--------------------------------------+
| admin_state_up | True |
| external_gateway_info | |
| id | f13fca0d-6ba9-4b9d-a842-e34dedbede2b |
| name | router1 |
| status | ACTIVE |
| tenant_id | 2e3986dd9ea643f4949223283299ddec |
+-----------------------+--------------------------------------+
[terry@f17-devstack1 quantum]$ quantum router-interface-add router1 subnet1
Added interface to router router1
[terry@f17-devstack1 quantum]$ quantum port-list
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------+
| 2486674a-8ce7-42ae-8b36-1a41d4a54606 | | fa:16:3e:7d:fe:66 | {"subnet_id": "02eb6689-04b0-4617-8bf9-10fddc2fa591", "ip_address": "10.10.10.1"} |
+--------------------------------------+------+-------------------+-----------------------------------------------------------------------------------+
[terry@f17-devstack1 quantum]$ quantum subnet-delete subnet1
Deleted subnet: subnet1
[terry@f17-devstack1 quantum]$ quantum port-list
+--------------------------------------+------+-------------------+-----------+
| id | name | mac_address | fixed_ips |
+--------------------------------------+------+-------------------+-----------+
| 2486674a-8ce7-42ae-8b36-1a41d4a54606 | | fa:16:3e:7d:fe:66 | |
+--------------------------------------+------+-------------------+-----------+
[terry@f17-devstack1 quantum]$ quantum port-delete 2486674a-8ce7-42ae-8b36-1a41d4a54606
Port 2486674a-8ce7-42ae-8b36-1a41d4a54606 has owner network:router_interface and therefore cannot be deleted directly via the port API.
[terry@f17-devstack1 quantum]$ quantum router-delete router1
Router f13fca0d-6ba9-4b9d-a842-e34dedbede2b still has active ports
[terry@f17-devstack1 quantum]$ quantum router-interface-delete 02eb6689-04b0-4617-8bf9-10fddc2fa591
usage: quantum router-interface-delete [-h] [--request-format {json,xml}]
                                       router-id subnet-id
quantum router-interface-delete: error: too few arguments
[terry@f17-devstack1 quantum]$ quantum router-interface-delete router1 02eb6689-04b0-4617-8bf9-10fddc2fa591
Unable to find subnet with name '02eb6689-04b0-4617-8bf9-10fddc2fa591'