famerico commented on issue #14664:
URL: https://github.com/apache/cloudstack/issues/14664#issuecomment-6772839466

   We found the root cause by reading the code on tag 4.22.1.1, and it is 
narrower than the title of this issue suggests.
   
   `KVMStoragePoolManager.disconnectPhysicalDiskByPath(path)` passes the local 
path of every disk of the VM to every registered adaptor. 
`IscsiAdmStorageAdaptor.disconnectPhysicalDiskByPath` only skips a path if it 
does not contain `-iscsi-`:
   
   ```java
   String search1 = "/dev/disk/by-path/ip-";
   ...
   if (!localPath.contains(search3)) {   // search3 = "-iscsi-"
       return false;
   }
   int index = localPath.indexOf(search2);   // search2 = ":"
   String host = localPath.substring(search1.length(), index);
   ```
   
   It then assumes a path shaped like 
`/dev/disk/by-path/ip-<host>:<port>-iscsi-<iqn>-lun-<n>`.
   
   In our setup the disk of the SharedMountPoint pool is `/mnt/<pool 
dir>/<uuid>`, and the pool directory name contains `-iscsi-`. The path is 58 
characters long, passes the `contains("-iscsi-")` check and has no `:`. 
`indexOf(":")` returns -1 and `search1.length()` is 21, which gives exactly the 
observed `Range [21, -1) out of bounds for length 58`.
   
   So the trigger is a mount path containing `-iscsi-`, not the storage being 
iSCSI-backed. A SharedMountPoint pool whose directory name does not contain 
that string should not hit this. We have not run that variant yet.
   
   Suggested fix: guard on the expected prefix 
(`localPath.startsWith(search1)`) and check that the `indexOf` results are not 
-1 before calling `substring`, returning false otherwise.
   
   Why the second Stop works is still not verified. Our hypothesis is that the 
first attempt already stops the domain and fails only in `cleanupDisk`, and the 
retry finds the VM stopped and does not run the cleanup again.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to