Steps to remove stale logical-port(s) in NSX-T after attempted delete
search cancel

Steps to remove stale logical-port(s) in NSX-T after attempted delete

book

Article ID: 319115

calendar_today

Updated On:

Products

VMware NSX

Issue/Introduction

  • While attempting to delete a logical port, that is you detached a VM from the segment, but the port is still present in the NSX-T UI.

  • Post removal of VMs, ports remain present in NSX and viewable in the two view states detailed below (Please see Admin Guide - Configure the User Interface Settings for details of switching between Policy and Manager view) : 
    • In policy view, for the segment, the segment port shows as Admin Status Up and Status Success
    • In manager view for the logical switch, Admin Status is Up, but Operational Status is Down.This can also be applied as a search filter as shown below by switching to Manager View > Network > Logical Switches > Ports then adding the "VM Ports Operational Down" filter.:

  • In the NSX-T manager log /var/log/search/search-manager.log you see the following log entries:
36804:20##-##-##T##:##:##.591Z INFO TopologyEventHandler TopologyIndexer 6090 - [nsx@6876 comp="nsx-manager" level="INFO" subcomp="manager"] No VIF found for attachment id:<Logical Port UUID>

Note:
The preceding log excerpts are only examples. Date, time, and environmental variables may vary depending on your environment.

Environment

VMware NSX
VMware NSX-T Data Center

Cause

The stale logical ports are left behind, when the detach operation occurred, due to the port delete not being successful and no retry mechanism being present.

Resolution

This is a known issue Impacting NSX-T.
Future enhancements are planned to NSX to auto cleanup existing stale ports. 

Please see additional info for scripted workaround if there are very large numbers of ports present. Below workaround is suited for low numbers of known ports..

Workaround:


In the NSX-T manager UI, under Policy view, find the port (Networking > Segments > click on blue number of Ports for Segment), click the ellipsis (3 vertical dots) of the port, and select the Delete option.

If this operation fails, you can use the below API call the with the HEADER x-allow-overwrite = true to remove the logical port:

  • DELETE /api/v1/logical-ports/<Logical-Port-UUID>?detach=true

  • Steps:

    • Login to the NSX-T manager as user admin.

    • Switch to root account using the command "st  en"

    • Run the following command to delete the logical-port(s)

      curl -l -k -u 'admin' -H 'Content-Type:application/json' -H 'X-Allow-Overwrite: true' -X DELETE "https://<nsx-manager-ip>/api/v1/logical-ports/<Logical Port UUID>?detach=true" 

      Where Logical Port UUID is the port id to be deleted.

      For example the below highlighted is the port id for VM <VM-name>. 



    • The port uuid  we can be obtained from the Manager view in NSX ie Networking ---> Logical Switches ---> Click on the Logical Switch


Alternatively, you can force delete the logical switch with the following API call directly, or in curl format: 

  • DELETE /api/v1/logical-switches/<logical-switch-UUID>?detach=true&cascade=true

  • curl -l -k -u 'admin' -H 'Content-Type:application/json' -H 'X-Allow-Overwrite: true' -X DELETE "https://<nsx-manager-ip>/api/v1/logical-switches/<logical-switch-UUID>?detach=true&cascade=true"
Name

Description

Type Notes
cascade Delete a Logical Switch and all the logical ports in it, if none of the logical ports have any attachment. boolean Default: "False"
detach Force delete a logical switch

If this is set to true, then logical switch is deleted
regardless of whether or not it is added to NSGroup.
If cascade is set to true in the meantime, then logical
switch and all logical ports are deleted regardless of
whether any logical port in this switch has attachments.
boolean Default: "False"

 

Additional Information

For additional information on the API details: NSX-T Data Center REST API

Related Knowledge Base articles

Scripted cleanup of stale ports - Scripted cleanup of stale logical ports on NSX segments