DaanHoogland commented on code in PR #6408:
URL: https://github.com/apache/cloudstack/pull/6408#discussion_r890858929


##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/VolumeOrchestrator.java:
##########
@@ -638,46 +655,57 @@ public VolumeInfo createVolume(VolumeInfo volume, 
VirtualMachine vm, VirtualMach
 
         pool = findStoragePool(dskCh, dc, pod, clusterId, vm.getHostId(), vm, 
avoidPools);
         if (pool == null) {
-            s_logger.warn("Unable to find suitable primary storage when 
creating volume " + volume.getName());
-            throw new CloudRuntimeException("Unable to find suitable primary 
storage when creating volume " + volume.getName());
+            String msg = String.format("Unable to find suitable primary 
storage when creating volume [%s].", volumeToString);
+            s_logger.error(msg);
+            throw new CloudRuntimeException(msg);
         }
 
+        String poolToString = getReflectOnlySelectedFields(pool);
+
         if (s_logger.isDebugEnabled()) {
-            s_logger.debug("Trying to create " + volume + " on " + pool);
+            s_logger.debug(String.format("Trying to create volume [%s] on 
storage pool [%s].",
+                    volumeToString, poolToString));
         }
         DataStore store = dataStoreMgr.getDataStore(pool.getId(), 
DataStoreRole.Primary);
         for (int i = 0; i < 2; i++) {
             // retry one more time in case of template reload is required for 
Vmware case
             AsyncCallFuture<VolumeApiResult> future = null;
-            boolean isNotCreatedFromTemplate = volume.getTemplateId() == null 
? true : false;
+            boolean isNotCreatedFromTemplate = (volumeInfo.getTemplateId() == 
null);
             if (isNotCreatedFromTemplate) {
-                future = volService.createVolumeAsync(volume, store);
+                future = volService.createVolumeAsync(volumeInfo, store);
             } else {
                 TemplateInfo templ = tmplFactory.getTemplate(template.getId(), 
DataStoreRole.Image);
-                future = volService.createVolumeFromTemplateAsync(volume, 
store.getId(), templ);
+                future = volService.createVolumeFromTemplateAsync(volumeInfo, 
store.getId(), templ);
             }
             try {
                 VolumeApiResult result = future.get();
                 if (result.isFailed()) {
                     if (result.getResult().contains(REQUEST_TEMPLATE_RELOAD) 
&& (i == 0)) {
-                        s_logger.debug("Retry template re-deploy for vmware");
+                        s_logger.debug(String.format("Retrying to deploy 
template [%s] for VMware, attempt 2/2. ", templateToString));
                         continue;
                     } else {
-                        s_logger.debug("create volume failed: " + 
result.getResult());
-                        throw new CloudRuntimeException("create volume 
failed:" + result.getResult());
+                        String msg = String.format("Failed to create volume 
[%s] due to [%s].", volumeToString, result.getResult());
+                        s_logger.error(msg);
+                        throw new CloudRuntimeException(msg);
                     }
                 }
 
                 return result.getVolume();
-            } catch (InterruptedException e) {
-                s_logger.error("create volume failed", e);
-                throw new CloudRuntimeException("create volume failed", e);
-            } catch (ExecutionException e) {
-                s_logger.error("create volume failed", e);
-                throw new CloudRuntimeException("create volume failed", e);
+            } catch (InterruptedException | ExecutionException e) {
+                String msg = String.format("Failed to create 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]

Reply via email to