Skip to content

Commit 620ed16

Browse files
VMware: Improve error messaging / logs when starting non-user VMs, and secondary storage not available or doesn't have enough capacity (apache#9207)
1 parent 6ee6603 commit 620ed16

File tree

3 files changed

+16
-18
lines changed

3 files changed

+16
-18
lines changed

engine/storage/image/src/main/java/org/apache/cloudstack/storage/image/manager/ImageStoreProviderManagerImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public int compare(DataStore store1, DataStore store2) {
201201

202202
// No store with space found
203203
s_logger.error(String.format("Can't find an image storage in zone with less than %d usage",
204-
Math.round(_statsCollector.getImageStoreCapacityThreshold()*100)));
204+
Math.round(_statsCollector.getImageStoreCapacityThreshold() * 100)));
205205
return null;
206206
}
207207

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/manager/VmwareManagerImpl.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceCon
562562

563563
@Override
564564
public Pair<String, Long> getSecondaryStorageStoreUrlAndId(long dcId) {
565-
566565
String secUrl = null;
567566
Long secId = null;
568567
DataStore secStore = _dataStoreMgr.getImageStoreWithFreeCapacity(dcId);
@@ -572,18 +571,17 @@ public Pair<String, Long> getSecondaryStorageStoreUrlAndId(long dcId) {
572571
}
573572

574573
if (secUrl == null) {
575-
// we are using non-NFS image store, then use cache storage instead
576-
s_logger.info("Secondary storage is not NFS, we need to use staging storage");
574+
s_logger.info("Secondary storage is either not having free capacity or not NFS, then use cache/staging storage instead");
577575
DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId);
578576
if (cacheStore != null) {
579577
secUrl = cacheStore.getUri();
580578
secId = cacheStore.getId();
581579
} else {
582-
s_logger.warn("No staging storage is found when non-NFS secondary storage is used");
580+
s_logger.warn("No cache/staging storage found when NFS secondary storage with free capacity not available or non-NFS secondary storage is used");
583581
}
584582
}
585583

586-
return new Pair<String, Long>(secUrl, secId);
584+
return new Pair<>(secUrl, secId);
587585
}
588586

589587
@Override
@@ -599,13 +597,12 @@ public List<Pair<String, Long>> getSecondaryStorageStoresUrlAndIdList(long dcId)
599597
}
600598

601599
if (urlIdList.isEmpty()) {
602-
// we are using non-NFS image store, then use cache storage instead
603-
s_logger.info("Secondary storage is not NFS, we need to use staging storage");
600+
s_logger.info("Secondary storage is either not having free capacity or not NFS, then use cache/staging storage instead");
604601
DataStore cacheStore = _dataStoreMgr.getImageCacheStore(dcId);
605602
if (cacheStore != null) {
606603
urlIdList.add(new Pair<>(cacheStore.getUri(), cacheStore.getId()));
607604
} else {
608-
s_logger.warn("No staging storage is found when non-NFS secondary storage is used");
605+
s_logger.warn("No cache/staging storage found when NFS secondary storage with free capacity not available or non-NFS secondary storage is used");
609606
}
610607
}
611608

plugins/hypervisors/vmware/src/main/java/com/cloud/hypervisor/vmware/resource/VmwareResource.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
import javax.naming.ConfigurationException;
4949
import javax.xml.datatype.XMLGregorianCalendar;
5050

51+
import com.cloud.capacity.CapacityManager;
5152
import com.cloud.hypervisor.vmware.mo.HostDatastoreBrowserMO;
5253
import com.vmware.vim25.FileInfo;
5354
import com.vmware.vim25.FileQueryFlags;
@@ -2279,15 +2280,15 @@ protected StartAnswer execute(StartCommand cmd) {
22792280
// attach ISO (for patching of system VM)
22802281
Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
22812282
String secStoreUrl = secStoreUrlAndId.first();
2282-
Long secStoreId = secStoreUrlAndId.second();
22832283
if (secStoreUrl == null) {
2284-
String msg = "secondary storage for dc " + _dcId + " is not ready yet?";
2284+
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",
2285+
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
22852286
throw new Exception(msg);
22862287
}
22872288

22882289
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
22892290
if (morSecDs == null) {
2290-
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl;
2291+
String msg = "Failed to prepare secondary storage on host, NFS secondary or cache store url: " + secStoreUrl + " in dc "+ _dcId;
22912292
throw new Exception(msg);
22922293
}
22932294
DatastoreMO secDsMo = new DatastoreMO(hyperHost.getContext(), morSecDs);
@@ -4613,15 +4614,15 @@ protected Answer execute(PrepareForMigrationCommand cmd) {
46134614
List<Pair<String, Long>> secStoreUrlAndIdList = mgr.getSecondaryStorageStoresUrlAndIdList(Long.parseLong(_dcId));
46144615
for (Pair<String, Long> secStoreUrlAndId : secStoreUrlAndIdList) {
46154616
String secStoreUrl = secStoreUrlAndId.first();
4616-
Long secStoreId = secStoreUrlAndId.second();
46174617
if (secStoreUrl == null) {
4618-
String msg = String.format("Secondary storage for dc %s is not ready yet?", _dcId);
4618+
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",
4619+
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
46194620
throw new Exception(msg);
46204621
}
46214622

46224623
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
46234624
if (morSecDs == null) {
4624-
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl;
4625+
String msg = "Failed to prepare secondary storage on host, NFS secondary or cache store url: " + secStoreUrl + " in dc "+ _dcId;
46254626
throw new Exception(msg);
46264627
}
46274628
}
@@ -7342,14 +7343,14 @@ private List<VolumeObjectTO> relocateVirtualMachine(final VmwareHypervisorHost h
73427343
VmwareManager mgr = targetHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
73437344
Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
73447345
String secStoreUrl = secStoreUrlAndId.first();
7345-
Long secStoreId = secStoreUrlAndId.second();
73467346
if (secStoreUrl == null) {
7347-
String msg = "secondary storage for dc " + _dcId + " is not ready yet?";
7347+
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",
7348+
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
73487349
throw new Exception(msg);
73497350
}
73507351
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnSpecificHost(secStoreUrl, targetHyperHost);
73517352
if (morSecDs == null) {
7352-
throw new Exception(String.format("Failed to prepare secondary storage on host, secondary store url: %s", secStoreUrl));
7353+
throw new Exception(String.format("Failed to prepare secondary storage on host, NFS secondary or cache store url: %s in dc %s", secStoreUrl, _dcId));
73537354
}
73547355
}
73557356

0 commit comments

Comments
 (0)