The status of a volume in its meta data (result of GetVolume) is used to check if it is detached or not.
Generally we don't make decision based on data in KV file and definitely not inside guest. Disk may be attached to some other VM. If neither refCnt nor mount map suggest disk is attached to this VM then we must issue attach to ESX. If it is already attached, it is a no-op from ESX perspective anyway.
@pshahzeb can you quickly confirm that this issue needs fixing, given the current code and the recent changes in the refcnt and mount logic. Setting to rafiki as it should be either fixed or dropped.
The status of a volume in its meta data (result of GetVolume) is used to check if it is detached or not. Generally we don't make decision based on data in KV file and definitely not inside guest. Disk may be attached to some other VM. If neither refCnt nor mount map suggest disk is attached to this VM then we must issue attach to ESX. If it is already attached, it is a no-op from ESX perspective anyway.