I ran into an issue today where a vApp wasn’t created successfully because of an API call to add a network to the vApp was made while the vApp was in a busy state. The vApp networking section was empty, but if you tried to add the network to the vApp manually, you would receive an error that the network already existed on the vApp. If you looked at the vApp through the API or REST client, no networks were visible, but the vCloud database was updated with the network.
When deleting vApp, the vApp went into a pending state and the following error was displayed.
java.lang.NullPointerException
at com.vmware.vcloud.dl.net.vappnetwork.impl.VAppNetworkManagerImpl.findVcdNetwork(VAppNetworkManagerImpl.java:2006)
at com.vmware.vcloud.dl.net.vappnetwork.impl.VAppNetworkManagerImpl.deleteFromDb(VAppNetworkManagerImpl.java:2110)
at com.vmware.ssdc.backend.services.impl.VAppManagerImpl.deleteFromDb(VAppManagerImpl.java:1204)
at com.vmware.ssdc.backend.services.impl.VAppManagerImpl.deleteVAppFromDb(VAppManagerImpl.java:1115)
at com.vmware.ssdc.backend.services.impl.VAppManagerImpl.deleteVAppFromDb(VAppManagerImpl.java:1075)
I reproduced the issue in my lab so I could experiment. Trying to delete the row in the database for the VM resulted in:
Now I knew what table contained the vApp network: vapp_logical_resource.
Delete the invalid database entries
I’m not the best with SQL so these queries are probably terrible but they work.
vApp name: direct
vApps Table: vm_container
Find the invalid entry in vapp_logical_resource
select vapp_logical_resource.id from vm_container inner join vapp_logical_resource on vm_container.sg_id = vapp_logical_resource.vapp_id where vm_container.name = ‘direct’
Delete the invalid entry from vapp_logical_resource
delete from vapp_logical_resource where id = (select vapp_logical_resource.id from vm_container inner join vapp_logical_resource on vm_container.sg_id = vapp_logical_resource.vapp_id where vm_container.name = ‘direct’)
Update vApp status
Now that the invalid database entry is gone, you should be able to delete the vApp through vCloud, but first you need to set the creation_status field for the vApp to RESOLVED to clear the pending status.
Check the current status
select name, creation_status from vm_container where name = ‘direct’
direct,DELETING_CONTENTS
Update the status
update vm_container set creation_status = ‘RESOLVED’ where name = ‘direct’
Now you can right-click the vApp and select delete.
Of course if you’re going to do this on a system you care about, make sure to back up the database, be careful and get confirmation from VMware support.