Yesterday I was trying to delete an Org vDC from vCloud Air portal and it was failing time and again. On checking vCloud Director in backend I was seeing error “Cannot delete VDC“
When I tried deleting it directly from vCD, it was bitching about some expired vApp templates and was asking to remove them first.
On checking the Expired items tab, I found that there were few expired vApps
When I tried deleting them, the operation failed with error
1 |
The requested operation could not be executed on VM "VMTest1(com.vmware.vcloud.entity.vm:c8439077-3148-4487-b268-32c8af845108)". Stop the VM and try again |
Similar error I was seeing in vCD UI.
I tried deleting it via API as GUI was not behaving like a good friend.
Fired below API
# curl -sik -H “Accept:application/*+xml;version=5.6” -H “x-vcloud-authorization:Auth” -X DELETE https://us-california-1-3.vchs.vmware.com/api/compute/api/vApp/vapp-63592b99-fe00-41f3-bfbd-dbe27d3e9258
On checking the status of task that was generated by above API call, I found it failed with “Internal server error” (not a helpful error message )
As a last resort, I checked the vApp status in VCDDB. Usually in these type of case you will see vApp in not a regular state i.e Resolved in the DB records. I used following validation queries
SELECT id, name, creation_status FROM vapp_vm WHERE creation_status != ‘RESOLVED’ AND name LIKE ‘%VMTest%’;
1 2 |
id name creation_status 0xC843907731484487B26832C8AF845108 VMTest1 DELETING_CONTENTS |
SELECT name,sg_id,creation_status FROM vm_container WHERE creation_status != ‘RESOLVED’ AND name LIKE ‘%VMTest%’;
1 2 |
name sg_id creation_status VMTest1-VApp 0x751CD6191A1545EABABF314C5756C8F9 DELETING_CONTENTS |
So the creation_status of vApp/VM was in Deleting_contents state and that is why any attempt to delete the same from GUI and API was failing. In this situation there is nothing you can do apart from doing a DB edit (not recommended generally) to change the creation_status of vApp/VM to RESOLVED
We need to fire below queries in VCDDB (Make sure to backup your db first)
UPDATE vapp_vm SET creation_status = ‘RESOLVED’ WHERE id = 0xC843907731484487B26832C8AF845108;
UPDATE vm_container SET creation_status = ‘RESOLVED’ WHERE sg_id = 0x751CD6191A1545EABABF314C5756C8F9;
Go back to vCD and right click on the expred vApp and click on Renew so that this expred vApp is added back to the vDC where it was created originally.
You may ask here why I did not deleted the expired item directly instead of doing a renew. Infact I tried it but again it failed and in turn it chnaged the vApp status to “deleting_contents” again.
Also if you read the error stack which I initially pasted, it clearly mention to “stop the VM”. Thats why I added the expired vApp back to vDC and performed a power cycle on it so that it clears the stale state in DB.
Once that was done, I had no further issues in deleting the vApp and Org vDC from vCD.
And that’s it for this post. I hope you find this post informational. Feel free to share this on social media if it is worth sharing. Be sociable 🙂