Skip to content

Commit a362bf2

Browse files
committed
linstor: improve heartbeat check with also asking linstor (apache#10105)
If a node doesn't have a DRBD connection to another node, additionally ask Linstor-Controller if the node is alive. Otherwise we would have simply said no and the node might still be alive. This is always the case in a non hyperconverged setup.
1 parent aeb84b0 commit a362bf2

File tree

3 files changed

+57
-5
lines changed

3 files changed

+57
-5
lines changed

plugins/storage/volume/linstor/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to Linstor CloudStack plugin will be documented in this file
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2024-12-13]
9+
10+
### Fixed
11+
12+
- Linstor heartbeat check now also ask linstor-controller if there is no connection between nodes
13+
814
## [2024-10-28]
915

1016
### Fixed

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStorageAdaptor.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import com.linbit.linstor.api.DevelopersApi;
4747
import com.linbit.linstor.api.model.ApiCallRc;
4848
import com.linbit.linstor.api.model.ApiCallRcList;
49+
import com.linbit.linstor.api.model.Node;
4950
import com.linbit.linstor.api.model.Properties;
5051
import com.linbit.linstor.api.model.ProviderKind;
5152
import com.linbit.linstor.api.model.Resource;
@@ -715,4 +716,19 @@ public long getUsed(LinstorStoragePool pool) {
715716
throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx);
716717
}
717718
}
719+
720+
public boolean isNodeOnline(LinstorStoragePool pool, String nodeName) {
721+
DevelopersApi linstorApi = getLinstorAPI(pool);
722+
try {
723+
List<Node> node = linstorApi.nodeList(Collections.singletonList(nodeName), Collections.emptyList(), null, null);
724+
if (node == null || node.isEmpty()) {
725+
return false;
726+
}
727+
728+
return Node.ConnectionStatusEnum.ONLINE.equals(node.get(0).getConnectionStatus());
729+
} catch (ApiException apiEx) {
730+
s_logger.error(apiEx.getMessage());
731+
throw new CloudRuntimeException(apiEx.getBestMessage(), apiEx);
732+
}
733+
}
718734
}

plugins/storage/volume/linstor/src/main/java/com/cloud/hypervisor/kvm/storage/LinstorStoragePool.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,52 @@ private String executeDrbdSetupStatus(OutputInterpreter.AllLinesParser parser) {
280280
return sc.execute(parser);
281281
}
282282

283+
private boolean checkLinstorNodeOnline(String nodeName) {
284+
return ((LinstorStorageAdaptor)_storageAdaptor).isNodeOnline(this, nodeName);
285+
}
286+
287+
/**
288+
* Checks output of drbdsetup status output if this node has any valid connection to the specified
289+
* otherNodeName.
290+
* If there is no connection, ask the Linstor controller if the node is seen online and return false if not.
291+
* If there is a connection but not connected(valid) return false.
292+
* @param output Output of the drbdsetup status --json command
293+
* @param otherNodeName Name of the node to check against
294+
* @return true if we could say that this node thinks the node in question is reachable, otherwise false.
295+
*/
283296
private boolean checkDrbdSetupStatusOutput(String output, String otherNodeName) {
284297
JsonParser jsonParser = new JsonParser();
285298
JsonArray jResources = (JsonArray) jsonParser.parse(output);
299+
boolean connectionFound = false;
286300
for (JsonElement jElem : jResources) {
287301
JsonObject jRes = (JsonObject) jElem;
288302
JsonArray jConnections = jRes.getAsJsonArray("connections");
289303
for (JsonElement jConElem : jConnections) {
290304
JsonObject jConn = (JsonObject) jConElem;
291-
if (jConn.getAsJsonPrimitive("name").getAsString().equals(otherNodeName)
292-
&& jConn.getAsJsonPrimitive("connection-state").getAsString().equalsIgnoreCase("Connected")) {
293-
return true;
305+
if (jConn.getAsJsonPrimitive("name").getAsString().equals(otherNodeName))
306+
{
307+
connectionFound = true;
308+
if (jConn.getAsJsonPrimitive("connection-state").getAsString()
309+
.equalsIgnoreCase("Connected")) {
310+
return true;
311+
}
294312
}
295313
}
296314
}
297-
LOGGER.warn(String.format("checkDrbdSetupStatusOutput: no resource connected to %s.", otherNodeName));
298-
return false;
315+
boolean otherNodeOnline = false;
316+
if (connectionFound) {
317+
LOGGER.warn(String.format(
318+
"checkingHeartBeat: connection found, but not in state 'Connected' to %s", otherNodeName));
319+
} else {
320+
LOGGER.warn(String.format(
321+
"checkingHeartBeat: no resource connected to %s, checking LINSTOR", otherNodeName));
322+
otherNodeOnline = checkLinstorNodeOnline(otherNodeName);
323+
}
324+
LOGGER.info(String.format(
325+
"checkingHeartBeat: other node %s is %s.",
326+
otherNodeName,
327+
otherNodeOnline ? "online on controller" : "down"));
328+
return otherNodeOnline;
299329
}
300330

301331
private String executeDrbdEventsNow(OutputInterpreter.AllLinesParser parser) {

0 commit comments

Comments
 (0)