@@ -279,22 +279,52 @@ private String executeDrbdSetupStatus(OutputInterpreter.AllLinesParser parser) {
279
279
return sc .execute (parser );
280
280
}
281
281
282
+ private boolean checkLinstorNodeOnline (String nodeName ) {
283
+ return ((LinstorStorageAdaptor )_storageAdaptor ).isNodeOnline (this , nodeName );
284
+ }
285
+
286
+ /**
287
+ * Checks output of drbdsetup status output if this node has any valid connection to the specified
288
+ * otherNodeName.
289
+ * If there is no connection, ask the Linstor controller if the node is seen online and return false if not.
290
+ * If there is a connection but not connected(valid) return false.
291
+ * @param output Output of the drbdsetup status --json command
292
+ * @param otherNodeName Name of the node to check against
293
+ * @return true if we could say that this node thinks the node in question is reachable, otherwise false.
294
+ */
282
295
private boolean checkDrbdSetupStatusOutput (String output , String otherNodeName ) {
283
296
JsonParser jsonParser = new JsonParser ();
284
297
JsonArray jResources = (JsonArray ) jsonParser .parse (output );
298
+ boolean connectionFound = false ;
285
299
for (JsonElement jElem : jResources ) {
286
300
JsonObject jRes = (JsonObject ) jElem ;
287
301
JsonArray jConnections = jRes .getAsJsonArray ("connections" );
288
302
for (JsonElement jConElem : jConnections ) {
289
303
JsonObject jConn = (JsonObject ) jConElem ;
290
- if (jConn .getAsJsonPrimitive ("name" ).getAsString ().equals (otherNodeName )
291
- && jConn .getAsJsonPrimitive ("connection-state" ).getAsString ().equalsIgnoreCase ("Connected" )) {
292
- return true ;
304
+ if (jConn .getAsJsonPrimitive ("name" ).getAsString ().equals (otherNodeName ))
305
+ {
306
+ connectionFound = true ;
307
+ if (jConn .getAsJsonPrimitive ("connection-state" ).getAsString ()
308
+ .equalsIgnoreCase ("Connected" )) {
309
+ return true ;
310
+ }
293
311
}
294
312
}
295
313
}
296
- s_logger .warn (String .format ("checkDrbdSetupStatusOutput: no resource connected to %s." , otherNodeName ));
297
- return false ;
314
+ boolean otherNodeOnline = false ;
315
+ if (connectionFound ) {
316
+ s_logger .warn (String .format (
317
+ "checkingHeartBeat: connection found, but not in state 'Connected' to %s" , otherNodeName ));
318
+ } else {
319
+ s_logger .warn (String .format (
320
+ "checkingHeartBeat: no resource connected to %s, checking LINSTOR" , otherNodeName ));
321
+ otherNodeOnline = checkLinstorNodeOnline (otherNodeName );
322
+ }
323
+ s_logger .info (String .format (
324
+ "checkingHeartBeat: other node %s is %s." ,
325
+ otherNodeName ,
326
+ otherNodeOnline ? "online on controller" : "down" ));
327
+ return otherNodeOnline ;
298
328
}
299
329
300
330
private String executeDrbdEventsNow (OutputInterpreter .AllLinesParser parser ) {
0 commit comments