DaanHoogland commented on code in PR #6408:
URL: https://github.com/apache/cloudstack/pull/6408#discussion_r890859485
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -563,68 +573,75 @@ public VolumeInfo createVolumeFromSnapshot(Volume volume,
Snapshot snapshot, Use
}
- protected DiskProfile createDiskCharacteristics(VolumeInfo volume,
VirtualMachineTemplate template, DataCenter dc, DiskOffering diskOffering) {
- if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO !=
template.getFormat()) {
+ protected DiskProfile createDiskCharacteristics(VolumeInfo volumeInfo,
VirtualMachineTemplate template, DataCenter dc, DiskOffering diskOffering) {
+ if (volumeInfo.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO
!= template.getFormat()) {
+ String templateToString = getReflectOnlySelectedFields(template);
+ String zoneToString = getReflectOnlySelectedFields(dc);
+
TemplateDataStoreVO ss =
_vmTemplateStoreDao.findByTemplateZoneDownloadStatus(template.getId(),
dc.getId(), VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
if (ss == null) {
- throw new CloudRuntimeException("Template " +
template.getName() + " has not been completely downloaded to zone " +
dc.getId());
+ throw new CloudRuntimeException(String.format("Template [%s]
has not been completely downloaded to the zone [%s].",
+ templateToString, zoneToString));
}
- return new DiskProfile(volume.getId(), volume.getVolumeType(),
volume.getName(), diskOffering.getId(), ss.getSize(),
diskOffering.getTagsArray(), diskOffering.isUseLocalStorage(),
+ return new DiskProfile(volumeInfo.getId(),
volumeInfo.getVolumeType(), volumeInfo.getName(), diskOffering.getId(),
ss.getSize(), diskOffering.getTagsArray(), diskOffering.isUseLocalStorage(),
diskOffering.isRecreatable(), Storage.ImageFormat.ISO !=
template.getFormat() ? template.getId() : null);
} else {
- return new DiskProfile(volume.getId(), volume.getVolumeType(),
volume.getName(), diskOffering.getId(), diskOffering.getDiskSize(),
diskOffering.getTagsArray(),
+ return new DiskProfile(volumeInfo.getId(),
volumeInfo.getVolumeType(), volumeInfo.getName(), diskOffering.getId(),
diskOffering.getDiskSize(), diskOffering.getTagsArray(),
diskOffering.isUseLocalStorage(),
diskOffering.isRecreatable(), null);
}
}
@DB
- public VolumeInfo copyVolumeFromSecToPrimary(VolumeInfo volume,
VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod,
Long clusterId, ServiceOffering offering,
+ public VolumeInfo copyVolumeFromSecToPrimary(VolumeInfo volumeInfo,
VirtualMachine vm, VirtualMachineTemplate template, DataCenter dc, Pod pod,
Long clusterId, ServiceOffering offering,
DiskOffering diskOffering,
List<StoragePool> avoids, long size, HypervisorType hyperType) throws
NoTransitionException {
+ String volumeToString =
getReflectOnlySelectedFields(volumeInfo.getVolume());
final HashSet<StoragePool> avoidPools = new
HashSet<StoragePool>(avoids);
- DiskProfile dskCh = createDiskCharacteristics(volume, template, dc,
diskOffering);
+ DiskProfile dskCh = createDiskCharacteristics(volumeInfo, template,
dc, diskOffering);
dskCh.setHyperType(vm.getHypervisorType());
storageMgr.setDiskProfileThrottling(dskCh, null, diskOffering);
// Find a suitable storage to create volume on
StoragePool destPool = findStoragePool(dskCh, dc, pod, clusterId,
null, vm, avoidPools);
if (destPool == null) {
- throw new CloudRuntimeException("Failed to find a suitable storage
pool to create Volume in the pod/cluster of the provided VM "+ vm.getUuid());
+ throw new CloudRuntimeException(String.format("Failed to find a
suitable storage pool in the pod/cluster of the provided VM [%s] to create the
volume in.", vm));
}
DataStore destStore = dataStoreMgr.getDataStore(destPool.getId(),
DataStoreRole.Primary);
- AsyncCallFuture<VolumeApiResult> future =
volService.copyVolume(volume, destStore);
+ AsyncCallFuture<VolumeApiResult> future =
volService.copyVolume(volumeInfo, destStore);
try {
VolumeApiResult result = future.get();
if (result.isFailed()) {
- s_logger.debug("copy volume failed: " + result.getResult());
- throw new CloudRuntimeException("copy volume failed: " +
result.getResult());
+ String msg = String.format("Copy of the volume [%s] failed due
to [%s].", volumeToString, result.getResult());
+ s_logger.error(msg);
+ throw new CloudRuntimeException(msg);
}
return result.getVolume();
- } catch (InterruptedException e) {
- s_logger.debug("Failed to copy volume: " + volume.getId(), e);
- throw new CloudRuntimeException("Failed to copy volume", e);
- } catch (ExecutionException e) {
- s_logger.debug("Failed to copy volume: " + volume.getId(), e);
- throw new CloudRuntimeException("Failed to copy volume", e);
+ } catch (InterruptedException | ExecutionException e) {
+ String msg = String.format("Failed to copy the volume [%s] due to
[%s].", volumeToString, e.getMessage());
+ s_logger.error(msg, e);
Review Comment:
please don“t log error with exception. If need be add a debug that logs the
stacktrace
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]