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


##########
engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java:
##########
@@ -1363,11 +1364,13 @@ private void 
createManagedVolumeCopyTemplateAsync(VolumeInfo volumeInfo, Primary
             primaryDataStore.setDetails(details);
 
             grantAccess(volumeInfo, destHost, primaryDataStore);
-            volumeInfo = volFactory.getVolume(volumeInfo.getId(), 
primaryDataStore);
-            // For Netapp ONTAP iscsiName or Lun path  is available only after 
grantAccess
-            String managedStoreTarget = 
ObjectUtils.defaultIfNull(volumeInfo.get_iScsiName(), volumeInfo.getUuid());
-            details.put(PrimaryDataStore.MANAGED_STORE_TARGET, 
managedStoreTarget);
-            primaryDataStore.setDetails(details);
+            if 
(DataStoreProvider.ONTAP_PLUGIN_NAME.equals(primaryDataStore.getStorageProviderName()))
 {
+                // For Netapp ONTAP iscsiName or Lun path  is available only 
after grantAccess
+                volumeInfo = volFactory.getVolume(volumeInfo.getId(), 
primaryDataStore);
+                String managedStoreTarget = 
ObjectUtils.defaultIfNull(volumeInfo.get_iScsiName(), volumeInfo.getUuid());

Review Comment:
   The MANAGED_STORE_TARGET detail used by hypervisor copy/attach logic can be 
null unless it’s recomputed after grantAccess(). Previously this code always 
updated it using a safe fallback (iScsiName or UUID), but now it only happens 
for ONTAP. To avoid null targets for other managed providers, always recompute 
MANAGED_STORE_TARGET after grantAccess(), while only refreshing volumeInfo from 
DB for ONTAP.



##########
plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/lifecycle/OntapPrimaryDatastoreLifecycle.java:
##########
@@ -337,9 +337,12 @@ public boolean attachZone(DataStore dataStore, ZoneScope 
scope, Hypervisor.Hyper
             logger.error("attachZone : Storage Pool not found for id: " + 
dataStore.getId());
             throw new CloudRuntimeException("Storage Pool not found for id: " 
+ dataStore.getId());
         }
-
+        if (!Hypervisor.HypervisorType.KVM.equals(hypervisorType)){
+            logger.error("attachZone : ONTAP primary storage is supported only 
for KVM hypervisor");
+            throw new CloudRuntimeException("ONTAP primary storage is 
supported only for KVM hypervisor");
+        }

Review Comment:
   Missing space before the opening brace in this newly added if-statement is 
inconsistent with the surrounding formatting and may trigger style checks.



##########
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())){
+                    volumeToAttach = _volsDao.findById(volumeToAttach.getId());
+                }

Review Comment:
   Missing spaces around the if-condition and opening brace deviates from the 
surrounding style and may trip formatting/checkstyle rules.



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