VMs have been deleted from vCenter but still show up in the vSAN datastore and cannot be deleted.
failed with the error 'Cannot delete file [vsanDatastore] <uuid>'
VMware Horizon 8.x
VMware vSAN 7.x
VMware vSAN 8.x
The issue is a result of how the object is created by VDI.
This is caused by the flag "ddb.deletable = false" being present in the vmdk descriptor file.
Use following workaround to delete the object.
Workaround:
The command below can be used to remove the line from all VMDK descriptor files in a given VM namespace.
.
sed -i '/ddb.deletable/d' /vmfs/volumes/vsanDatastore/VM-Namespace/*.vmdk
After performing this change, the file/folder can be deleted via the vSphere Client in the datastore browser.
VMs created via the VDI client have "ddb.deletable = false" flag in the vmdk descriptor to protect it against accidental deletion.