Skip to content

Commit a5c0f5d

Browse files
sureshanapartidhslove
authored andcommitted
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 0e09335 commit a5c0f5d

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public int compare(DataStore store1, DataStore store2) {
202202

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

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

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ public List<ManagedObjectReference> addHostToPodCluster(VmwareContext serviceCon
560560

561561
@Override
562562
public Pair<String, Long> getSecondaryStorageStoreUrlAndId(long dcId) {
563-
564563
String secUrl = null;
565564
Long secId = null;
566565
DataStore secStore = _dataStoreMgr.getImageStoreWithFreeCapacity(dcId);
@@ -570,18 +569,17 @@ public Pair<String, Long> getSecondaryStorageStoreUrlAndId(long dcId) {
570569
}
571570

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

584-
return new Pair<String, Long>(secUrl, secId);
582+
return new Pair<>(secUrl, secId);
585583
}
586584

587585
@Override
@@ -597,13 +595,12 @@ public List<Pair<String, Long>> getSecondaryStorageStoresUrlAndIdList(long dcId)
597595
}
598596

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

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

Lines changed: 10 additions & 9 deletions
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;
@@ -2277,15 +2278,15 @@ protected StartAnswer execute(StartCommand cmd) {
22772278
// attach ISO (for patching of system VM)
22782279
Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
22792280
String secStoreUrl = secStoreUrlAndId.first();
2280-
Long secStoreId = secStoreUrlAndId.second();
22812281
if (secStoreUrl == null) {
2282-
String msg = "secondary storage for dc " + _dcId + " is not ready yet?";
2282+
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",
2283+
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
22832284
throw new Exception(msg);
22842285
}
22852286

22862287
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnHost(secStoreUrl);
22872288
if (morSecDs == null) {
2288-
String msg = "Failed to prepare secondary storage on host, secondary store url: " + secStoreUrl;
2289+
String msg = "Failed to prepare secondary storage on host, NFS secondary or cache store url: " + secStoreUrl + " in dc "+ _dcId;
22892290
throw new Exception(msg);
22902291
}
22912292
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
}
@@ -7343,14 +7344,14 @@ private List<VolumeObjectTO> relocateVirtualMachine(final VmwareHypervisorHost h
73437344
VmwareManager mgr = targetHyperHost.getContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
73447345
Pair<String, Long> secStoreUrlAndId = mgr.getSecondaryStorageStoreUrlAndId(Long.parseLong(_dcId));
73457346
String secStoreUrl = secStoreUrlAndId.first();
7346-
Long secStoreId = secStoreUrlAndId.second();
73477347
if (secStoreUrl == null) {
7348-
String msg = "secondary storage for dc " + _dcId + " is not ready yet?";
7348+
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",
7349+
_dcId, Math.round(CapacityManager.SecondaryStorageCapacityThreshold.value() * 100));
73497350
throw new Exception(msg);
73507351
}
73517352
ManagedObjectReference morSecDs = prepareSecondaryDatastoreOnSpecificHost(secStoreUrl, targetHyperHost);
73527353
if (morSecDs == null) {
7353-
throw new Exception(String.format("Failed to prepare secondary storage on host, secondary store url: %s", secStoreUrl));
7354+
throw new Exception(String.format("Failed to prepare secondary storage on host, NFS secondary or cache store url: %s in dc %s", secStoreUrl, _dcId));
73547355
}
73557356
}
73567357

0 commit comments

Comments
 (0)