nsx_cleanup.py cleanup script fails to delete Load Balancer Virtual Servers
search cancel

nsx_cleanup.py cleanup script fails to delete Load Balancer Virtual Servers

book

Article ID: 427101

calendar_today

Updated On:

Products

VMware NSX

Issue/Introduction

  • You need to clean up TKGi objects from NSX that has already been decommissioned
  • You're using the the nsx_cleanup.py script to remove manager objects as you no longer have access to the container
  • The script successfully removes the cluster and most related objects.
  • However, it fails to remove the Load Balancer Virtual Servers, Load Balancer and related objects associated with that cluster.

    ERROR: Failed to delete <Virtual Server Name> , error {
      "httpStatus" : "BAD_REQUEST",
      "error_code" : 23803,
      "module_name" : "LOAD-BALANCER",
      "error_message" : "Entity id LoadBalancerVirtualServer/<Virtual Server UUID> can not be deleted as it is being referenced by entity LoadBalancerService/<Load Balancer UUID>."

    Note:
  • nsx_cleanup.py script should only be used to clean up old TKGi (PKS) objects created by NCP. VMware don't support using this script to clean up TKGi.
  • If you do still have access to the TKGi containers, follow this cleanup method: How to clean up NSX Protected objects created by TKGi
  • This procedure should never be used on a working TKGI cluster. It is only safe to use if the cluster creation or deletion has failed and a complete cluster cleanup (deletion) is required.

Environment

VMware NSX

Cause

The nsx_cleanup.py script is unable to automatically delete the Virtual Servers because the Load Balancer Service remains active, creating a dependency that blocks the deletion of associated objects.

Resolution

You must manually remove the Load Balancer service with the API call:
DELETE /api/v1/loadbalancer/services/<LB UUID>

As it's a protected object, add the additional API header "X-Allow-Overwrite: true" to allow you to overwrite.

Example with curl:
curl -k -u admin -H "Content-Type: application/json" -H "X-Allow-Overwrite: true" -X DELETE https://<NSX Manager IP>/api/v1/loadbalancer/services/<LB UUID>

You can now run the cleanup script again to remove the remaining objects.

Additional Information

Cleaning Up the NSX Environment
How to clean up NSX Protected objects created by TKGi