ERROR ActivityWorkerPool-1-8 LogicalPortUtilsNsxT 4724 POLICY [nsx@6876 comp="nsx-manager" errorCode="PM503040" level="ERROR" subcomp="manager"] Segment /infra/segments/##########-####-####-####-#########:dvportgroup-42 has VMs attached. Please disconnect all VMs before deleting a segment.
WARN ActivityWorkerPool-1-18 ActivityExecutor 4713 - [nsx@6876 comp="nsx-manager" level="WARNING" subcomp="manager"] Phase execution failed. Activity= Activity= 'RemoveNsxFromComputeCollectionActivity:########-####-####-####-############' entity= 'ComputeCollectionMsg/#########-####-####-####-############:domain-c313262', Error= 'ActivityFailureException', phase= '{}'com.vmware.nsx.management.common.exceptions.InvalidArgumentException: nullVMware NSX
The uninstallation fails as NSX is unable to delete the segment due to stale logical ports.
Note: Stale ports may happen in an environment for different reasons.
Workaround
POST: /policy/api/v1/infra/sites/default/enforcement-points/default/transport-node-collections/<transport-node-collection-id>?action=remove_nsxNote: To find out the Transport Node Collection TNC which we want to delete use the following API:GET /policy/api/v1/infra/sites/default/enforcement-points/default/transport-node-collections/
From the above output API, search for the TNC entity which is referred in the exception error above as ComputeCollectionMsg.
For additional information on the API details: NSX-T Data Center REST API
Related Knowledge Base articles
Scripted Cleanup Of Stale Ports - KB324256