There are several published methods for removing objects that have become stuck in vRA however these are normally related to virtual machines experiencing some sort of infrastructure failure part way through deployment, resulting in them being stuck in one of the lifecycle states.
This blog article relates to those objects (including all non-vm objects) that cannot be removed by any cloud client or SQL based store procedure methods.
The route of last resort is to mark these objects as deleted within the vRA Postgres database which is a 2 part process.
Part 1 – Verify you can find the object within the database before you try and delete it. To do this you first need to establish an SSH session to the vRA appliance that has the MASTER postgres role. If you have a single node then it can only be that node, however if you have a vRA cluster then this can be found by looking at the cluster tab on any of the vRA appliances management web pages (port 5480) to identify the right node.
Once connected to the vRA appliance and logged in as root, you need to connect to the postgres database. This is done via a series of commands as follows:
- cd /opt/vmware/vpostgres/current/bin
- ./psql -U postgres
- \c vcac
At this point you are connected to the vcac database and can now try and locate the right object to delete by running the following command:
SELECT * FROM cat_resource WHERE name='<object name>’ and tenant_id='<tenant name>’;
The quotes in the command must be included however the brackets are just to denote text to be replaced with whatever your object names and tenant names are. If the command pulls back a single row then you are good to proceed to step 2. If the command pulls back more than one result then further investigation should be performed as proceeding may remove more than the object you are concerned with.
Part 2 – If you have correctly identified the object to remove in part 1 then the following command can be run to mark the object as deleted.
update cat_resource set status = ‘DELETED’ where name = ‘<machine name>’ and tenant_id='<tenant name>’;
As before make sure you include the quote marks but not the angular brackets. The command should reply that a single record has been updated. At this point you should be able to refresh your ‘Items’ tab in vRA and the orphaned objects should now be removed.