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


##########
server/src/main/java/com/cloud/storage/StorageManagerImpl.java:
##########
@@ -4011,6 +4019,70 @@ public ImageStore discoverImageStore(String name, String 
url, String providerNam
         return (ImageStore)_dataStoreMgr.getDataStore(store.getId(), 
DataStoreRole.Image);
     }
 
+    private void validateSecondaryStorageMount(Long zoneId, ImageStoreVO 
store) {
+
+    if (zoneId == null) {
+        return;
+    }
+
+    List<HostVO> ssvmHosts = 
_ssVmMgr.listUpAndConnectingSecondaryStorageVmHost(zoneId);
+
+    String failureReason = "No active Secondary Storage VM available in zone 
to validate the NFS mount.";
+
+    if (ssvmHosts == null || ssvmHosts.isEmpty()) {
+        cleanupImageStore(store.getId(), store.getUuid());

Review Comment:
   It would be good to perform this validation before persisting the secondary 
storage in the database, so that we don't need to perform any cleanup 
afterwards. You can create a "dummy" `NfsTO` to use for the 
`SecStorageSetupCommand`.



##########
server/src/main/java/com/cloud/storage/StorageManagerImpl.java:
##########
@@ -3989,6 +3996,7 @@ public ImageStore discoverImageStore(String name, String 
url, String providerNam
             }
             throw new CloudRuntimeException("Failed to add data store: " + 
e.getMessage(), e);
         }
+        validateSecondaryStorageMount(zoneId, (ImageStoreVO) store);

Review Comment:
   As this method is NFS-specific, could it be moved to 
`org.apache.cloudstack.storage.datastore.lifecycle.CloudStackImageStoreLifeCycleImpl#initialize`?



##########
server/src/main/java/com/cloud/storage/StorageManagerImpl.java:
##########
@@ -4011,6 +4019,70 @@ public ImageStore discoverImageStore(String name, String 
url, String providerNam
         return (ImageStore)_dataStoreMgr.getDataStore(store.getId(), 
DataStoreRole.Image);
     }
 
+    private void validateSecondaryStorageMount(Long zoneId, ImageStoreVO 
store) {

Review Comment:
   Identation needs fixing. Also, can part of this method be unified with 
`org.apache.cloudstack.secondarystorage.SecondaryStorageManagerImpl#generateSetupCommand`?



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