Description of the issue
There is an issue with the new rescan method introduced in PR https://github.com/IBM/ubiquity/pull/294 that the unmount didn't clean up the physical devices.
More detail : In the new cleanup proceduce, we get the multipath devices belonging to the same volume from multipath -ll output, but it happens in ActionAfterDetach, before that, a multipath -f is called, which will remove the volume record from the multipath -ll output. So that we can't get what we want, and the command "echo 1 > /sys/block/sdx/device/delete" won't be called. It will lead to stale info (stale paths in /dev/disk/by-path/) on host.
Description of the optimal solution - will not done in this PR
Change the order of the flex unmount as follow:
multipath -f
echo 1 > /sys/block/sdx/device/delete
unmap
rescan or cleanup in ActionAfterDetach doesn't help much.
Description of the solution
But reordering the steps is a big change, will do it in next release. For the current release, I'll use a local cache to store the informations required in the cleanup phase(vol wwn\lun\multipath device and list of physical devices), so that we can cleanup the paths even if it is not in the multipath -ll output.
Detail about the cache
The cache is a "map[volumeWWn]*VolumeMountProperties" (in fact it is a sync.Map, which is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination).Each key-value stands for a volume which is mounted to the current host by flex. The value VolumeMountProperties is a struct which has 4 attributes: WWN, LunNUbmer, DeviceMapper("mpthx"), Devices (["sda", "sdb", ...]) and stands for a multipath device and all its paths.
Coverage remained the same at 66.484% when pulling 82e54ee39a2571e5d5b0d9efe415a61c51eaca76 on feature/UB-1941_unmount_fix into 91b55dc79980d23ad6668457a0002c956f3591c8 on dev.
Description of the issue There is an issue with the new rescan method introduced in PR https://github.com/IBM/ubiquity/pull/294 that the unmount didn't clean up the physical devices. More detail : In the new cleanup proceduce, we get the multipath devices belonging to the same volume from multipath -ll output, but it happens in ActionAfterDetach, before that, a multipath -f is called, which will remove the volume record from the multipath -ll output. So that we can't get what we want, and the command "echo 1 > /sys/block/sdx/device/delete" won't be called. It will lead to stale info (stale paths in /dev/disk/by-path/) on host.
Description of the optimal solution - will not done in this PR Change the order of the flex unmount as follow:
rescan or cleanup in ActionAfterDetach doesn't help much.
Description of the solution But reordering the steps is a big change, will do it in next release. For the current release, I'll use a local cache to store the informations required in the cleanup phase(vol wwn\lun\multipath device and list of physical devices), so that we can cleanup the paths even if it is not in the multipath -ll output.
Detail about the cache The cache is a "map[volumeWWn]*VolumeMountProperties" (in fact it is a sync.Map, which is like a Go map[interface{}]interface{} but is safe for concurrent use by multiple goroutines without additional locking or coordination).Each key-value stands for a volume which is mounted to the current host by flex. The value VolumeMountProperties is a struct which has 4 attributes: WWN, LunNUbmer, DeviceMapper("mpthx"), Devices (["sda", "sdb", ...]) and stands for a multipath device and all its paths.
This change is