Skip to content

Commit 44d28f1

Browse files
Pearl1594Pearl Dsilva
andauthored
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>
1 parent 8cc70c7 commit 44d28f1

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,6 @@ private List<RouterHealthCheckResult> updateDbHealthChecksFromRouterResponse(fin
15311531
} catch (JsonSyntaxException ex) {
15321532
s_logger.error("Unable to parse the result of health checks due to " + ex.getLocalizedMessage(), ex);
15331533
}
1534-
15351534
return Collections.emptyList();
15361535
}
15371536

utils/src/main/java/com/cloud/utils/ssh/SshHelper.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
189189

190190
byte[] buffer = new byte[8192];
191191
StringBuffer sbResult = new StringBuffer();
192-
193192
int currentReadBytes = 0;
194193
while (true) {
195194
throwSshExceptionIfStdoutOrStdeerIsNull(stdout, stderr);
@@ -207,22 +206,18 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
207206
if (canEndTheSshConnection(waitResultTimeoutInMs, sess, conditions)) {
208207
break;
209208
}
210-
211209
}
212210

213-
while (stdout.available() > 0) {
214-
currentReadBytes = stdout.read(buffer);
215-
sbResult.append(new String(buffer, 0, currentReadBytes));
211+
while((currentReadBytes = stdout.read(buffer)) != -1) {
212+
sbResult.append(new String(buffer, 0 , currentReadBytes));
216213
}
217214

218-
while (stderr.available() > 0) {
219-
currentReadBytes = stderr.read(buffer);
215+
while((currentReadBytes = stderr.read(buffer)) != -1) {
220216
sbResult.append(new String(buffer, 0, currentReadBytes));
221217
}
222218
}
223219

224220
String result = sbResult.toString();
225-
226221
if (StringUtils.isBlank(result)) {
227222
try {
228223
result = IOUtils.toString(stdout, StandardCharsets.UTF_8);
@@ -243,7 +238,6 @@ public static Pair<Boolean, String> sshExecute(String host, int port, String use
243238
s_logger.error(String.format("SSH execution of command %s has an error status code in return. Result output: %s", command, result));
244239
return new Pair<Boolean, String>(false, result);
245240
}
246-
247241
return new Pair<Boolean, String>(true, result);
248242
} finally {
249243
if (sess != null)

0 commit comments

Comments
 (0)