Skip to content

Commit

Permalink
[grid] No need to register a Node that is DOWN
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Aug 3, 2022
1 parent 7ce42b7 commit a9a526e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions java/src/org/openqa/selenium/grid/distributor/GridModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public void purgeDeadNodes() {
for (NodeStatus node : nodes) {
NodeId id = node.getNodeId();
if (nodeHealthCount.getOrDefault(id, 0) > UNHEALTHY_THRESHOLD) {
LOG.info(String.format("Removing Node %s, unhealthy threshold has been reached",
node.getExternalUri()));
toRemove.add(node);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ private void register(NodeStatus status) {
return;
}

if (status.getAvailability() != UP) {
// A Node might be draining or down (in the case of Relay nodes)
// but the heartbeat is still running.
// We do not need to add this Node for now.
return;
}

Set<Capabilities> capabilities = status.getSlots().stream()
.map(Slot::getStereotype)
.map(ImmutableCapabilities::copyOf)
Expand Down Expand Up @@ -314,9 +321,10 @@ public LocalDistributor add(Node node) {
NodeStatus initialNodeStatus;
try {
initialNodeStatus = node.getStatus();
if (initialNodeStatus.getAvailability() == DRAINING) {
// A Node might be draining but the heartbeat is still running.
// We do not need to add this Node again.
if (initialNodeStatus.getAvailability() != UP) {
// A Node might be draining or down (in the case of Relay nodes)
// but the heartbeat is still running.
// We do not need to add this Node for now.
return this;
}
model.add(initialNodeStatus);
Expand Down Expand Up @@ -383,13 +391,13 @@ private Runnable asRunnableHealthCheck(Node node) {
return () -> {
boolean checkFailed = false;
Exception failedCheckException = null;
LOG.log(getDebugLogLevel(), "Running health check for " + node.getUri());
LOG.log(getDebugLogLevel(), "Running healthcheck for Node " + node.getUri());

HealthCheck.Result result;
try {
result = healthCheck.check();
} catch (Exception e) {
LOG.log(Level.WARNING, "Unable to process node " + id, e);
LOG.log(Level.WARNING, "Unable to process Node healthcheck " + id, e);
result = new HealthCheck.Result(DOWN, "Unable to run healthcheck. Assuming down");
checkFailed = true;
failedCheckException = e;
Expand Down

0 comments on commit a9a526e

Please sign in to comment.