utils: handle EOFException during VR Health Check (#3919)

VR health check throws EOFException due to malformed/Invalid JSON.

Fixes #3893

Co-authored-by: Pearl Dsilva <pearl.dsilva@shapeblue.com>
This commit is contained in:
Pearl Dsilva 2020-03-06 13:30:53 +05:30 committed by GitHub
parent 8cc70c7d87
commit 44d28f1994
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 10 deletions

View File

@ -1531,7 +1531,6 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
} catch (JsonSyntaxException ex) {
s_logger.error("Unable to parse the result of health checks due to " + ex.getLocalizedMessage(), ex);
}
return Collections.emptyList();
}

View File

@ -189,7 +189,6 @@ public class SshHelper {
byte[] buffer = new byte[8192];
StringBuffer sbResult = new StringBuffer();
int currentReadBytes = 0;
while (true) {
throwSshExceptionIfStdoutOrStdeerIsNull(stdout, stderr);
@ -207,22 +206,18 @@ public class SshHelper {
if (canEndTheSshConnection(waitResultTimeoutInMs, sess, conditions)) {
break;
}
}
while (stdout.available() > 0) {
currentReadBytes = stdout.read(buffer);
sbResult.append(new String(buffer, 0, currentReadBytes));
while((currentReadBytes = stdout.read(buffer)) != -1) {
sbResult.append(new String(buffer, 0 , currentReadBytes));
}
while (stderr.available() > 0) {
currentReadBytes = stderr.read(buffer);
while((currentReadBytes = stderr.read(buffer)) != -1) {
sbResult.append(new String(buffer, 0, currentReadBytes));
}
}
String result = sbResult.toString();
if (StringUtils.isBlank(result)) {
try {
result = IOUtils.toString(stdout, StandardCharsets.UTF_8);
@ -243,7 +238,6 @@ public class SshHelper {
s_logger.error(String.format("SSH execution of command %s has an error status code in return. Result output: %s", command, result));
return new Pair<Boolean, String>(false, result);
}
return new Pair<Boolean, String>(true, result);
} finally {
if (sess != null)