anuragaw commented on a change in pull request #3276: [DO NOT MERGE WIP] Add 
more states for attaching disk in allocated state
URL: https://github.com/apache/cloudstack/pull/3276#discussion_r276564979
 
 

 ##########
 File path: server/src/com/cloud/storage/VolumeApiServiceImpl.java
 ##########
 @@ -1920,12 +1920,13 @@ private Volume orchestrateDetachVolumeFromVM(long 
vmId, long volumeId) {
             // Mark the volume as detached
             _volsDao.detachVolume(volume.getId());
 
-            // volume.getPoolId() should be null if the VM we are detaching 
the disk from has never been started before
-            DataStore dataStore = volume.getPoolId() != null ? 
dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary) : null;
-
-            volService.revokeAccess(volFactory.getVolume(volume.getId()), 
host, dataStore);
-
-            handleTargetsForVMware(hostId, volumePool.getHostAddress(), 
volumePool.getPort(), volume.get_iScsiName());
+            // volumePool() should be null if the VM we are detaching the disk 
from has never been started before
+            // only revoke access on volumes that are actually on a datastore
+            if (volumePool != null) {
 
 Review comment:
   If the volumePool was null initially the dataStore was null and revokeAccess 
did nothing. Also I don't think it should be null as the 
```handleTargetsForVMWare(hostId,volumePool.getHostAddress()...``` would crash.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to