Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions server/src/main/java/com/cloud/storage/StorageManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.VirtualMachine.State;
import com.cloud.vm.dao.VMInstanceDao;
import com.cloud.storage.secondary.SecondaryStorageVmManager;
import com.google.common.collect.Sets;


Expand Down Expand Up @@ -344,6 +345,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
@Inject
protected VolumeDao volumeDao;
@Inject
protected SecondaryStorageVmManager _ssVmMgr;
@Inject
ConfigurationDao _configDao;
@Inject
ManagementServer _msServer;
Expand Down Expand Up @@ -3990,6 +3993,37 @@ public ImageStore discoverImageStore(String name, String url, String providerNam
throw new CloudRuntimeException("Failed to add data store: " + e.getMessage(), e);
}

// Validate secondary storage mount immediately using SSVM
if (zoneId != null) {
List<HostVO> ssvmHosts = _hostDao.listByType(Host.Type.SecondaryStorageVM);
boolean mountSuccess = false;
String failureReason = "No Secondary Storage VM available to validate the NFS mount.";

for (HostVO ssvm : ssvmHosts) {
if (ssvm.getDataCenterId() != zoneId.longValue()) {
continue;
}

Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
try {
boolean result = _ssVmMgr.generateSetupCommand(ssvm.getId());
if (result) {
mountSuccess = true;
break;
} else {
failureReason = "Secondary Storage VM failed to mount the NFS secondary storage.";
}
} catch (Exception e) {
failureReason = e.getMessage();
}
}

if (!mountSuccess) {
// cleanup created store
_imageStoreDao.remove(store.getId());
Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
throw new CloudRuntimeException("Invalid secondary storage mount: " + failureReason);
}
}
Comment thread
DaanHoogland marked this conversation as resolved.
Outdated

Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
Comment on lines 3998 to 4000
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lifeCycle.initialize(params) returns a DataStore implementation (e.g., ImageStoreEntity), not an ImageStoreVO. The cast (ImageStoreVO) store will throw ClassCastException at runtime (and the cast is evaluated even when zoneId is null). Consider changing validateSecondaryStorageMount to accept DataStore/ImageStoreEntity (or storeId/uuid), and fetch/update the ImageStoreVO via _imageStoreDao.findById(store.getId()) when you need to persist the parent path.

Copilot uses AI. Check for mistakes.
if (((ImageStoreProvider)storeProvider).needDownloadSysTemplate()) {
// trigger system vm template download
_imageSrv.downloadBootstrapSysTemplate(store);
Expand Down
Loading