VMware: Improve error messaging / logs when starting non-user VMs, and secondary storage not available or doesn't have enough capacity (#9207)

This commit is contained in:
Suresh Kumar Anaparti 2024-06-25 12:25:42 +05:30 committed by GitHub
parent 6ee6603359
commit 620ed164d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 18 deletions

View File

@ -201,7 +201,7 @@ public class ImageStoreProviderManagerImpl implements ImageStoreProviderManager,
// No store with space found // No store with space found
s_logger.error(String.format("Can't find an image storage in zone with less than %d usage", s_logger.error(String.format("Can't find an image storage in zone with less than %d usage",
Math.round(_statsCollector.getImageStoreCapacityThreshold()*100))); Math.round(_statsCollector.getImageStoreCapacityThreshold() * 100)));
return null; return null;
} }

View File

@ -562,7 +562,6 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
@Override @Override
public Pair<String, Long> getSecondaryStorageStoreUrlAndId(long dcId) { public Pair<String, Long> getSecondaryStorageStoreUrlAndId(long dcId) {
String secUrl = null; String secUrl = null;
Long secId = null; Long secId = null;
DataStore secStore = _dataStoreMgr.getImageStoreWithFreeCapacity(dcId); DataStore secStore = _dataStoreMgr.getImageStoreWithFreeCapacity(dcId);
@ -572,18 +571,17 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
} }
if (secUrl == null) { if (secUrl == null) {
// we are using non-NFS image store, then use cache storage instead s_logger.info("Secondary storage is either not having free capacity or not NFS, then use cache/staging storage instead");
s_logger.info("Secondary storage is not NFS, we need to use staging storage");
DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId); DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId);
if (cacheStore != null) { if (cacheStore != null) {
secUrl = cacheStore.getUri(); secUrl = cacheStore.getUri();
secId = cacheStore.getId(); secId = cacheStore.getId();
} else { } else {
s_logger.warn("No staging storage is found when non-NFS secondary storage is used"); s_logger.warn("No cache/staging storage found when NFS secondary storage with free capacity not available or non-NFS secondary storage is used");
} }
} }
return new Pair<String, Long>(secUrl, secId); return new Pair<>(secUrl, secId);
} }
@Override @Override
@ -599,13 +597,12 @@ public class VmwareManagerImpl extends ManagerBase implements VmwareManager, Vmw
} }
if (urlIdList.isEmpty()) { if (urlIdList.isEmpty()) {
// we are using non-NFS image store, then use cache storage instead s_logger.info("Secondary storage is either not having free capacity or not NFS, then use cache/staging storage instead");
s_logger.info("Secondary storage is not NFS, we need to use staging storage");
DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId); DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId);
if (cacheStore != null) { if (cacheStore != null) {
urlIdList.add(new Pair<>(cacheStore.getUri(), cacheStore.getId())); urlIdList.add(new Pair<>(cacheStore.getUri(), cacheStore.getId()));
} else { } else {
s_logger.warn("No staging storage is found when non-NFS secondary storage is used"); s_logger.warn("No cache/staging storage found when NFS secondary storage with free capacity not available or non-NFS secondary storage is used");
} }
} }

View File

@ -48,6 +48,7 @@ import java.util.stream.Collectors;
import javax.naming.ConfigurationException; import javax.naming.ConfigurationException;
import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.XMLGregorianCalendar;
import com.cloud.capacity.CapacityManager;
import com.cloud.hypervisor.vmware.mo.HostDatastoreBrowserMO; import com.cloud.hypervisor.vmware.mo.HostDatastoreBrowserMO;
import com.vmware.vim25.FileInfo; import com.vmware.vim25.FileInfo;
import com.vmware.vim25.FileQueryFlags; import com.vmware.vim25.FileQueryFlags;
@ -2279,15 +2280,15 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
// attach ISO (for patching of system VM) // attach ISO (for patching of system VM)
Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId)); Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
String secStoreUrl = secStoreUrlAndId.first(); String secStoreUrl = secStoreUrlAndId.first();
Long secStoreId = secStoreUrlAndId.second();
if (secStoreUrl == null) { if (secStoreUrl == null) {
String msg = "secondary storage for dc " + _dcId + " is not ready yet?"; String msg = String.format("NFS secondary or cache storage of dc %s either doesn't have enough capacity (has reached %d%% usage threshold) or not ready yet, or non-NFS secondary storage is used",
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
throw new Exception(msg); throw new Exception(msg);
} }
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl); ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
if (morSecDs == null) { if (morSecDs == null) {
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl; String msg = "Failed to prepare secondary storage on host, NFS secondary or cache store url: " + secStoreUrl + " in dc "+ _dcId;
throw new Exception(msg); throw new Exception(msg);
} }
DatastoreMO secDsMo = new DatastoreMO(hyperHost.getContext(), morSecDs); DatastoreMO secDsMo = new DatastoreMO(hyperHost.getContext(), morSecDs);
@ -4613,15 +4614,15 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
List<Pair<String, Long>> secStoreUrlAndIdList = mgr.getSecondaryStorageStoresUrlAndIdList(Long.parseLong(_dcId)); List<Pair<String, Long>> secStoreUrlAndIdList = mgr.getSecondaryStorageStoresUrlAndIdList(Long.parseLong(_dcId));
for (Pair<String, Long> secStoreUrlAndId : secStoreUrlAndIdList) { for (Pair<String, Long> secStoreUrlAndId : secStoreUrlAndIdList) {
String secStoreUrl = secStoreUrlAndId.first(); String secStoreUrl = secStoreUrlAndId.first();
Long secStoreId = secStoreUrlAndId.second();
if (secStoreUrl == null) { if (secStoreUrl == null) {
String msg = String.format("Secondary storage for dc %s is not ready yet?", _dcId); String msg = String.format("NFS secondary or cache storage of dc %s either doesn't have enough capacity (has reached %d%% usage threshold) or not ready yet, or non-NFS secondary storage is used",
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
throw new Exception(msg); throw new Exception(msg);
} }
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl); ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
if (morSecDs == null) { if (morSecDs == null) {
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl; String msg = "Failed to prepare secondary storage on host, NFS secondary or cache store url: " + secStoreUrl + " in dc "+ _dcId;
throw new Exception(msg); throw new Exception(msg);
} }
} }
@ -7342,14 +7343,14 @@ public class VmwareResource extends ServerResourceBase implements StoragePoolRes
VmwareManager mgr = targetHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME); VmwareManager mgr = targetHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId)); Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
String secStoreUrl = secStoreUrlAndId.first(); String secStoreUrl = secStoreUrlAndId.first();
Long secStoreId = secStoreUrlAndId.second();
if (secStoreUrl == null) { if (secStoreUrl == null) {
String msg = "secondary storage for dc " + _dcId + " is not ready yet?"; String msg = String.format("NFS secondary or cache storage of dc %s either doesn't have enough capacity (has reached %d%% usage threshold) or not ready yet, or non-NFS secondary storage is used",
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
throw new Exception(msg); throw new Exception(msg);
} }
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnSpecificHost(secStoreUrl, targetHyperHost); ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnSpecificHost(secStoreUrl, targetHyperHost);
if (morSecDs == null) { if (morSecDs == null) {
throw new Exception(String.format("Failed to prepare secondary storage on host, secondary store url: %s", secStoreUrl)); throw new Exception(String.format("Failed to prepare secondary storage on host, NFS secondary or cache store url: %s in dc %s", secStoreUrl, _dcId));
} }
} }