Commit 292d3a8f authored by Ali Fahs's avatar Ali Fahs
Browse files

better handling of the logs

parent b3724477
Pipeline #18277 passed with stage
in 1 minute and 49 seconds
......@@ -48,7 +48,7 @@ public class ByonAgentAutomation {
LOGGER.info("Running the script on the BYON node ");
sshConnection.executeSSHCommand(SCRIPT_DIR, false);
} catch (JSchException | InterruptedException e) {
LOGGER.error("An error while preparing the node: \n " + e.getStackTrace());
LOGGER.error("An error while preparing the node: ", e);
}
}
......@@ -63,10 +63,10 @@ public class ByonAgentAutomation {
sshConnection.executeSSHCommand("sudo chown " + username + ":" + username + " " + logFile, logFileFlag);
} catch (JSchException | InterruptedException e) {
LOGGER.error("An error while creating the log file: \n" + e.getStackTrace());
LOGGER.error("An error while creating the log file: " , e);
} finally {
logFileFlag = true;
LOGGER.info("Byon SSH logs are saved at: " + logFile);
LOGGER.info("Byon SSH logs are saved at: {}", logFile);
}
}
}
......@@ -82,8 +82,7 @@ public class ByonAgentAutomation {
scriptURL = DEBIAN_SCRIPT;
break;
default:
LOGGER.error("The Operating System \"" + os + "\" does not support automated configuration," +
" the installation of ProActive node agent should be done manually");
LOGGER.error("The Operating System \"{}\" does not support automated configuration, the installation of ProActive node agent should be done manually", os);
throw new IllegalArgumentException("The OS does not support automated configuration");
// code block
}
......
......@@ -48,7 +48,7 @@ public class SSHConnection {
channel = (ChannelExec) session.openChannel("exec");
channel.setCommand(command);
LOGGER.info("Executing on " + host + ": " + command);
LOGGER.info("Executing on {}: {}", host, command);
ByteArrayOutputStream responseStream = new ByteArrayOutputStream();
channel.setOutputStream(responseStream, true);
channel.setErrStream(responseStream, true);
......@@ -58,14 +58,14 @@ public class SSHConnection {
Thread.sleep(100);
}
if (channel.getExitStatus() != 0) {
LOGGER.error("An error occurred while executing the command, please check the logfile: " + logFile);
LOGGER.error("An error occurred while executing the command, please check the logfile: {}", logFile);
}
String responseString = new String(responseStream.toByteArray());
if (!responseString.equals("")) {
LOGGER.info("The Output of the command is: \n" + responseString);
LOGGER.info("The Output of the command is: {}", responseString);
}
} catch (JSchException | InterruptedException e) {
LOGGER.error("An error occurred while Executing an SSH command on " + host);
LOGGER.error("An error occurred while Executing an SSH command on {}", host);
throw e;
} finally {
if (session != null) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment