Orphaned container volumes cannot be deleted through vSphere Client
book
Article ID: 396706
calendar_today
Updated On:
Products
VMware vSphere Kubernetes Service
Issue/Introduction
The associated vmdk files for the container volumes, pvc, pv has already been deleted.
The container volumes are only showing on the vCenter UI : vCenter > datastore > Monitor > Cloud Native Storage > Container Volumes
From the guest cluster or workload cluster, we will get an empty result if we run:
k get pvc,pv -A | grep "pvc_name_showing_in_the_vCenter_UI"
Restarting the csi-controller pod does not make any changes.
We can find the pvc from from VCDB using sample volume id: hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh
/opt/vmware/vpostgres/current/bin/psql -d VCDB -U postgres -c "SELECT * from vpx_storage_object_info where id='hhhhhhhh-hhhh-hhhh-hhhh-hhhhhhhhhhhh'"
The 'delete disk' column flag is set to 'false' - this is because it is unable to find the vmdk that is associated with it.
From /var/log/vmware/vsan-health/vsanvcmgmtd.log we observe following events :
info vsanvcmgmtd[######] [vSAN@#### sub=Workflow opID=xxx-#######-####] Workflow Delete volume suspended for vim.Task:task-######, due to async action StartDeleteVolume Workflow Delete volume suspended Delete a virtual storage object : The object or item referred to could not be found
Additional symptoms reported:
OpenShift and vCenter integration using vSphere CSI Driver where PVC was created and later deleted from OpenShift.
Volume no longer associated with any pod but still appears in vCenter.
Error occurs when attempting to delete the volume object from vCenter.
vCenter shows volume associated with a VMDK file that doesn't exist on the datastore.
Container volumes become orphaned after deletion from Kubernetes/OpenShift clusters.
Environment
VMware vCenter Server 7.0
VMware vCenter Server 8.0
Cause
Deleting the vmdk directly from the datastore int the /fcd directory is not the ideal way to delete the pvc or pv.
Since the associated vmdk files for the container volumes has already been deleted the container volumes has become stale/orphan.
Resolution
The ideal way to delete pvc and pv remains to be from the cli of respective guest cluster/workload cluster (in this case).
k get pvc,pv -n namespace_name
k delete pvc_complete_name -n namespace_name
k delete pv_complete_name -n namespace_name
If the vmdk has been mistakenly deleted, please refer the below steps :
Download & extract the govc binary in the vCenter's /tmp directory.
Create a cns-vols-to-delete.txt file in the VCenter:
vi cns-vols-to-delete.txt
Inside the text file, update the volume ID of the container volume that we want to remove. (Output from step 6)
Run this remove command:
xargs -a cns-vols-to-delete.txt -I{} -d'\n' govc volume.rm {}
If the govc utility fails to delete it will give an output as : govc : object not found. The only option at this point is to reconcile the datastore inventory :