From 923a5a4425fe6e8263ab17ca6a39ecd6d3695531 Mon Sep 17 00:00:00 2001 From: Pearl Dsilva Date: Thu, 28 Apr 2022 21:31:15 +0530 Subject: [PATCH] Improve log when live patching fails (#6324) --- utils/src/main/java/com/cloud/utils/FileUtil.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/utils/src/main/java/com/cloud/utils/FileUtil.java b/utils/src/main/java/com/cloud/utils/FileUtil.java index 3a44127fe14..d9bf0817687 100644 --- a/utils/src/main/java/com/cloud/utils/FileUtil.java +++ b/utils/src/main/java/com/cloud/utils/FileUtil.java @@ -38,7 +38,7 @@ public class FileUtil { } public static void scpPatchFiles(String controlIp, String destPath, int sshPort, File pemFile, String[] files, String basePath) { - String errMsg = "Failed to scp files to system VM"; + String finalErrMsg = ""; List srcFiles = Arrays.asList(files); srcFiles = srcFiles.stream() .map(file -> basePath + file) // Using Lambda notation to update the entries @@ -50,10 +50,11 @@ public class FileUtil { destPath, newSrcFiles, "0755"); return; } catch (Exception e) { - errMsg += ", retrying"; - s_logger.error(errMsg); + finalErrMsg = String.format("Failed to scp files to system VM due to, %s", + e.getCause() != null ? e.getCause().getLocalizedMessage() : e.getLocalizedMessage()); + s_logger.error(finalErrMsg); } } - throw new CloudRuntimeException(errMsg); + throw new CloudRuntimeException(finalErrMsg); } }