Removing a vSphere Cloud account fails with message 'Cannot delete cloud zone as it is being used by: <Project_name>
search cancel

Removing a vSphere Cloud account fails with message 'Cannot delete cloud zone as it is being used by: <Project_name>

book

Article ID: 325917

calendar_today

Updated On:

Products

VCF Operations/Automation (formerly VMware Aria Suite)

Issue/Introduction

Delete a stale vSphere Cloud Account.

Symptoms:

  • There are no Blueprints or deployments mapped to the concern cloud account from Overview of Cloud zone.
  • The vSphere cloud account in VMware Aria Automation 8.x is stale now and the status from the UI will report a warning.
  • When removing the project associated with the cloud zone or cloud account it fails with below message
    Some of your changes could not be applied: Cannot delete with active resources:1
  • The backing vCenter is already decommissioned for some reason.



Environment

VMware Aria Automation 8.x

Cause

  • This is most commonly caused by machine resources associated with the project which may be in a provisioning status.
  • You may also use APIs to get the Machines and its details.
    • Refer to the Workaround section in this article.

Resolution

See the Workaround section for additional information. ( Before proceeding with the steps below, please take snapshots of all nodes in the cluster to ensure data integrity and facilitate potential rollbacks if needed. )

Workaround:

  1. From the Postman connect to vRA 
  2. Filter the machines with 'provisioningStatus' reporting PROVISIONING
  3. Make a note of those Id and delete the once which are incorrect status(provisioningStatus) and from the decommissioned cloud account
    API : https://{base-url}/iaas/api/machines/
    Method : GET
Note: Iaas API by default as a limit of first 100 Elements and in-case you have more than 100 Elements then you can do pagination. The API will look similar to the below example:
GET https://{base-url}/iaas/api/machines/?$top=1000 
Note: You may define the top Elements as per your Environment and in this case, I had to set it to 3900. And you can also use skip if you want to go page by page (?$top=100&$skip=100)
  1. Make a note of the Machine ID from previous GET API 
Note: The GET API will give you deploymentID and also the ID of the machine, ensure to capture the ID
Example: The one highlighted in green is what we need.
 "deploymentId": "83xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx",
            "provisioningStatus": "READY",
            "customProperties": {
                "image": "CentOs",
                "osType": "LINUX",
                "vcUuid": "75xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
                "provisionGB": "16",
                "softwareName": "CentOS 7 (64-bit)",
                "datastoreName": "Saveme1",
                "resourceGroupName": "",
                "cpuCount": "1",
                "memoryInMB": "1024",
                "imageProfileId": "45xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                "flavorProfileId": "45xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
            },
            "externalId": "50xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx",
            "name": "Cloud_Machine_1-xxxxxx-xxxxxxxxxxxxx",
            "id": "d7xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxxx",
  1. Delete API
    API : /iaas/api/machines/{Id}?forceDelete=true
    Method : DELETE
    Ex: DELETE https://{base-url}/iaas/api/machines/d7xxxxxx-xxxx-xxxx-xxxx-3axxxxxxxxxx?forceDelete=true
Example: You will receive the status of the delete and an ID to monitor the progress:
 {
    "progress": 0,
    "status": "INPROGRESS",
    "name": "Provisioning",
    "id": "20xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "selfLink": "/iaas/api/request-tracker/20xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
  1. Monitor the delete request with API
    API : /iaas/api/request-tracker/{request-id}
    Method : GET 
Example: GET https://{base-url}/iaas/api/request-tracker/20xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  1. Repeat the same, until you have cleared all the resources associated with this project. Then attempt to remove the Cloud Account.