winterhazel commented on code in PR #13578:
URL: https://github.com/apache/cloudstack/pull/13578#discussion_r3575995018


##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -5092,6 +5093,13 @@ private VolumeVO sendAttachVolumeCommand(UserVmVO vm, 
VolumeVO volumeToAttach, L
 
                     throw new CloudRuntimeException(e.getMessage());
                 }
+
+                // Reload volume from DB after grantAccess — managed storage 
drivers (e.g. ONTAP)
+                // may update the volume's path and iScsiName during 
grantAccess, so the local
+                // volumeToAttach object can be stale.
+                
if(DataStoreProvider.ONTAP_PLUGIN_NAME.equals(volumeToAttachStoragePool.getStorageProviderName())){

Review Comment:
   ```suggestion
                   if (volumeToAttachStoragePool != null && 
DataStoreProvider.ONTAP_PLUGIN_NAME.equals(volumeToAttachStoragePool.getStorageProviderName()))
 {
   ```
   
   Thanks for already adding the check here. A single remark: it would be nice 
to include a  `volumeToAttachStoragePool != null` here to prevent a NPE. 
According to L5074, `volumeToAttachStoragePool` is null when the VM we are 
attaching the disk to has never been started before.
   
   (also, when `volumeToAttachStoragePool` is null, 
`volService.grantAccess(...)` does not do anything because it will not be able 
to find the provider's driver (current behavior), so this extra condition 
should not be a problem for the ONTAP plugin)



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