Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1812433

Summary: Unable to delete an instance | Conflict: Port [port-id] is currently a parent port for trunk [trunk-id]
Product: Red Hat OpenStack Reporter: Ravi Singh <ravsingh>
Component: openstack-neutronAssignee: Slawek Kaplonski <skaplons>
Status: CLOSED WONTFIX QA Contact: Eran Kuris <ekuris>
Severity: high Docs Contact:
Priority: high    
Version: 13.0 (Queens)CC: amuller, camorris, chrisw, cmuresan, dhill, jraju, ljozsa, m.andre, mdemaced, njohnston, scohen, skaplons
Target Milestone: ---Keywords: Triaged, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-01-13 11:35:38 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ravi Singh 2020-03-11 10:48:43 UTC
Description of problem:

Attempting to delete instance failed with error in nova-compute

~~~
2020-03-04 09:52:46.257 1 WARNING nova.network.neutronv2.api [req-0dd45fe4-861c-46d3-a5ec-7db36352da58 02c6d1bc10fe4ffaa289c786cd09b146 695c417810ac460480055b074bc41817 - default default] [instance: 2f9e3740-b425-4f00-a949-e1aacf2239c4] Failed to delete port 991e4e50-481a-4ca6-9ea6-69f848c4ca9f for instance.: Conflict: Port 991e4e50-481a-4ca6-9ea6-69f848c4ca9f is currently a parent port for trunk 5800ee0f-b558-46cb-bb0b-92799dbe02cf.
~~~

Version-Release number of selected component (if applicable):

OSP13

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:
Should able to delete an instance.

Additional info:

Comment 3 Nate Johnston 2020-03-12 13:32:32 UTC
*** Bug 1749473 has been marked as a duplicate of this bug. ***

Comment 15 Nate Johnston 2020-04-01 16:48:13 UTC
So here is how the logic works in Neutron now.  When you create a trunk in Neutron you create a parent port for the trunk and attach the trunk to the parent.  Then subports can be created on the trunk.  When instances are created on the trunk, first a port is created and then an instance is associated with a free port.  That's the oversight in the logic!  

From the perspective of the code, the parent port looks like any other port attached to the trunk bridge.  It doesn't have an instance attached to it so it looks like it's not being used for anything (which is technically correct).  So it becomes an eligible port for an instance to bind to.  It's fairly rare that an instance will actually bind to it, but that is what happened for the customer in this case.  That is all fine and dandy until you go to delete the instance and you get the "Port [port-id] is currently a parent port for trunk [trunk-id]" exception just as happened here.

So the code fix is to correct the oversight and mark the parent port for the trunk as owned by the trunk bridge, which will avoid this scenario.  The initial solution which had been contributed a long time ago was merged upstream, but then reverted as it made the API slower, so we'll be pushing a speed-optimized version of the fix upstream sometime today.

Comment 22 Martin André 2020-06-08 09:05:18 UTC
The issue seems to be that neutron sometime misses the transition to DOWN when the attached VM is deleted, presumably a race condition when it's under load.

Thanks to Luis Tomas Bolivar I was able to destroy the rogue trunk by provisioning a VM on the parent port that I later deleted. This allowed to reset the port status, permitting us to delete the trunk:

moc-ci ❯ openstack network trunk show 7ivxcxg8-3c054-mpb8n-worker-k6g7x
+-----------------+-----------------------------------------------------------------------------------------------------------------------------+
| Field           | Value                                                                                                                       |
+-----------------+-----------------------------------------------------------------------------------------------------------------------------+
| admin_state_up  | UP                                                                                                                          |
| created_at      | 2020-04-03T07:28:02Z                                                                                                        |
| description     |                                                                                                                             |
| id              | 41e2e4c3-94cf-4700-bd2b-66e07aed8a26                                                                                        |
| name            | 7ivxcxg8-3c054-mpb8n-worker-k6g7x                                                                                           |
| port_id         | 18755388-2b1a-40e2-b771-b6696c3d9713                                                                                        |
| project_id      | 593227d1d5d04cba8847d5b6b742e0a7                                                                                            |
| revision_number | 8                                                                                                                           |
| status          | ACTIVE                                                                                                                      |
| sub_ports       |                                                                                                                             |
| tags            | ['cluster-api-provider-openstack', 'openshift-machine-api-7ivxcxg8-3c054-mpb8n', 'openshiftClusterID=7ivxcxg8-3c054-mpb8n'] |
| tenant_id       | 593227d1d5d04cba8847d5b6b742e0a7                                                                                            |
| updated_at      | 2020-05-08T17:58:17Z                                                                                                        |
+-----------------+-----------------------------------------------------------------------------------------------------------------------------+

moc-ci ❯ openstack port show 18755388-2b1a-40e2-b771-b6696c3d9713
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                   | Value                                                                                                                                                                          |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up          | DOWN                                                                                                                                                                           |
| allowed_address_pairs   | ip_address='10.0.0.5', mac_address='fa:16:3e:90:ce:26'                                                                                                                         |
|                         | ip_address='10.0.0.6', mac_address='fa:16:3e:90:ce:26'                                                                                                                         |
|                         | ip_address='10.0.0.7', mac_address='fa:16:3e:90:ce:26'                                                                                                                         |
| binding_host_id         | None                                                                                                                                                                           |
| binding_profile         | None                                                                                                                                                                           |
| binding_vif_details     | None                                                                                                                                                                           |
| binding_vif_type        | None                                                                                                                                                                           |
| binding_vnic_type       | normal                                                                                                                                                                         |
| created_at              | 2020-04-03T07:28:00Z                                                                                                                                                           |
| data_plane_status       | None                                                                                                                                                                           |
| description             |                                                                                                                                                                                |
| device_id               |                                                                                                                                                                                |
| device_owner            | compute:nova                                                                                                                                                                   |
| dns_assignment          | None                                                                                                                                                                           |
| dns_domain              | None                                                                                                                                                                           |
| dns_name                | None                                                                                                                                                                           |
| extra_dhcp_opts         |                                                                                                                                                                                |
| fixed_ips               | ip_address='10.0.0.24', subnet_id='23ece209-6a21-45c7-ba43-b7ec9e01c4e7'                                                                                                       |
| id                      | 18755388-2b1a-40e2-b771-b6696c3d9713                                                                                                                                           |
| location                | cloud='moc-ci', project.domain_id='default', project.domain_name=, project.id='593227d1d5d04cba8847d5b6b742e0a7', project.name='rh-openshift-ci', region_name='moc-kzn', zone= |
| mac_address             | fa:16:3e:90:ce:26                                                                                                                                                              |
| name                    | 7ivxcxg8-3c054-mpb8n-worker-k6g7x                                                                                                                                              |
| network_id              | 79bc266f-1496-4e1b-bde9-8ef112dab00c                                                                                                                                           |
| port_security_enabled   | True                                                                                                                                                                           |
| project_id              | 593227d1d5d04cba8847d5b6b742e0a7                                                                                                                                               |
| propagate_uplink_status | None                                                                                                                                                                           |
| qos_policy_id           | None                                                                                                                                                                           |
| resource_request        | None                                                                                                                                                                           |
| revision_number         | 19                                                                                                                                                                             |
| security_group_ids      | 5e3b9d71-3c9b-475b-a2d6-7d24c09f6e3b                                                                                                                                           |
| status                  | ACTIVE                                                                                                                                                                         |
| tags                    | cluster-api-provider-openstack, openshift-machine-api-7ivxcxg8-3c054-mpb8n, openshiftClusterID=7ivxcxg8-3c054-mpb8n                                                            |
| trunk_details           | {'trunk_id': '41e2e4c3-94cf-4700-bd2b-66e07aed8a26', 'sub_ports': []}                                                                                                          |
| updated_at              | 2020-04-29T13:50:40Z                                                                                                                                                           |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

moc-ci ❯ openstack network trunk delete 41e2e4c3-94cf-4700-bd2b-66e07aed8a26                                                                                                                                         
Failed to delete trunk with name or ID '41e2e4c3-94cf-4700-bd2b-66e07aed8a26': Trunk 41e2e4c3-94cf-4700-bd2b-66e07aed8a26 is currently in use.                                                                       
Neutron server returns request_ids: ['req-d31133c2-f820-4d9f-b3f1-f04a7647c612']                                                                                                                                     
1 of 1 trunks failed to delete.                                                                                                                                                                                      

moc-ci ❯ openstack port delete 18755388-2b1a-40e2-b771-b6696c3d9713                                                                                                                                                  
Failed to delete port with name or ID '18755388-2b1a-40e2-b771-b6696c3d9713': ConflictException: 409: Client Error for url: https://<redacted>/v2.0/ports/18755388-2b1a-40e2-b771-b6696c3d9713, Port
 18755388-2b1a-40e2-b771-b6696c3d9713 is currently a parent port for trunk 41e2e4c3-94cf-4700-bd2b-66e07aed8a26.                                                                                                     
1 of 1 ports failed to delete.                                                                                                                                                                                       

moc-ci ❯ openstack server create --security-group default --image cirros --key-name mandre --flavor m1.small --nic port-id=18755388-2b1a-40e2-b771-b6696c3d9713 --wait mandre-test                                 

moc-ci ❯ openstack server delete mandre-test

moc-ci ❯ openstack network trunk delete 41e2e4c3-94cf-4700-bd2b-66e07aed8a26