rg9975 commented on code in PR #8889:
URL: https://github.com/apache/cloudstack/pull/8889#discussion_r1634944307


##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java:
##########
@@ -207,31 +215,53 @@ public boolean connectPhysicalDisk(String volumePath, 
KVMStoragePool pool, Map<S
 
     @Override
     public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool 
pool) {
-        
LOGGER.debug(String.format("disconnectPhysicalDiskByPath(volumePath,pool) 
called with args (%s, %s) START", volumePath, pool.getUuid()));
+        if (LOGGER.isDebugEnabled()) 
LOGGER.debug(String.format("disconnectPhysicalDisk(volumePath,pool) called with 
args (%s, %s) START", volumePath, pool.getUuid()));
         AddressInfo address = this.parseAndValidatePath(volumePath);
+        if (address.getAddress() == null) {
+            if (LOGGER.isDebugEnabled()) 
LOGGER.debug(String.format("disconnectPhysicalDisk(volumePath,pool) returning 
FALSE, volume path has no address field", volumePath, pool.getUuid()));
+            return false;
+        }
         ScriptResult result = runScript(disconnectScript, 60000L, 
address.getAddress().toLowerCase());
-        if (LOGGER.isDebugEnabled()) LOGGER.debug("multipath flush output: " + 
result.getResult());
-        
LOGGER.debug(String.format("disconnectPhysicalDiskByPath(volumePath,pool) 
called with args (%s, %s) COMPLETE [rc=%s]", volumePath, pool.getUuid(), 
result.getResult()));        return true;
+        if (LOGGER.isDebugEnabled()) {
+            LOGGER.debug("multipath flush output: " + result.getResult());
+            
LOGGER.debug(String.format("disconnectPhysicalDisk(volumePath,pool) called with 
args (%s, %s) COMPLETE [rc=%s]", volumePath, pool.getUuid(), 
result.getResult()));
+        }
+        return true;
     }
 
     @Override
     public boolean disconnectPhysicalDisk(Map<String, String> 
volumeToDisconnect) {
-        
LOGGER.debug(String.format("disconnectPhysicalDiskByPath(volumeToDisconnect) 
called with arg bag [not implemented]:") + " " + volumeToDisconnect);
+        LOGGER.debug(String.format("disconnectPhysicalDisk(volumeToDisconnect) 
called with arg bag [not implemented]:") + " " + volumeToDisconnect);
         return false;
     }
 
     @Override
     public boolean disconnectPhysicalDiskByPath(String localPath) {
-        LOGGER.debug(String.format("disconnectPhysicalDiskByPath(localPath) 
called with args (%s) STARTED", localPath));
-        ScriptResult result = runScript(disconnectScript, 60000L, 
localPath.replace("/dev/mapper/3", ""));
-        if (LOGGER.isDebugEnabled()) LOGGER.debug("multipath flush output: " + 
result.getResult());
-        LOGGER.debug(String.format("disconnectPhysicalDiskByPath(localPath) 
called with args (%s) COMPLETE [rc=%s]", localPath, result.getExitCode()));     
  return true;
+        if (localPath == null) {
+            return false;
+        }
+        if (LOGGER.isDebugEnabled()) 
LOGGER.debug(String.format("disconnectPhysicalDiskByPath(localPath) called with 
args (%s) START", localPath));
+        if (localPath.startsWith("/dev/mapper/")) {
+            String multipathName = localPath.replace("/dev/mapper/3", "");
+            // this ensures we only disconnect multipath devices supported by 
this driver
+            for (String oui: SUPPORTED_OUI_LIST) {
+                if (multipathName.length() > 1 && 
multipathName.substring(2).startsWith(oui)) {
+                    ScriptResult result = runScript(disconnectScript, 60000L, 
multipathName);

Review Comment:
   Addressed in 310a35b85a.



##########
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/storage/MultipathSCSIAdapterBase.java:
##########
@@ -207,31 +215,53 @@ public boolean connectPhysicalDisk(String volumePath, 
KVMStoragePool pool, Map<S
 
     @Override
     public boolean disconnectPhysicalDisk(String volumePath, KVMStoragePool 
pool) {
-        
LOGGER.debug(String.format("disconnectPhysicalDiskByPath(volumePath,pool) 
called with args (%s, %s) START", volumePath, pool.getUuid()));
+        if (LOGGER.isDebugEnabled()) 
LOGGER.debug(String.format("disconnectPhysicalDisk(volumePath,pool) called with 
args (%s, %s) START", volumePath, pool.getUuid()));
         AddressInfo address = this.parseAndValidatePath(volumePath);
+        if (address.getAddress() == null) {
+            if (LOGGER.isDebugEnabled()) 
LOGGER.debug(String.format("disconnectPhysicalDisk(volumePath,pool) returning 
FALSE, volume path has no address field", volumePath, pool.getUuid()));
+            return false;
+        }
         ScriptResult result = runScript(disconnectScript, 60000L, 
address.getAddress().toLowerCase());

Review Comment:
   Addressed in 310a35b85a.



-- 
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