You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "winterhazel (via GitHub)" <gi...@apache.org> on 2026/03/28 21:58:15 UTC

Re: [PR] storage: validate NFS secondary storage mount using SSVM during image store discovery [cloudstack]

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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org