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


##########
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 (volumeToAttachStoragePool != null && 
DataStoreProvider.ONTAP_PLUGIN_NAME.equals(volumeToAttachStoragePool.getStorageProviderName()))
 {
+                    volumeToAttach = _volsDao.findById(volumeToAttach.getId());
+                }

Review Comment:
   After the ONTAP-specific reload, _volsDao.findById(...) can return null 
(e.g., concurrent delete or DB issue). That would cause a NullPointerException 
later when volumeToAttach is dereferenced (getPath/get_iScsiName/etc.). Add a 
null-check and fail fast with a clear exception.



##########
plugins/storage/volume/ontap/pom.xml:
##########
@@ -105,21 +103,13 @@
         <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
-            <version>${mockito.version}</version>
+            <version>${cs.mockito.version}</version>
             <scope>test</scope>

Review Comment:
   This module’s tests use Mockito.mockStatic(...) (static mocking), but the 
POM no longer includes mockito-inline and there is no 
mockito-extensions/org.mockito.plugins.MockMaker file in the repo. With only 
mockito-core on the classpath, static mocking will fail at runtime. Re-add 
mockito-inline (test scope) or add the inline mock-maker extension file.



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