Skip to content

Commit 0795e78

Browse files
committed
Ensure that default healthcheck duration is less than node timeout duration
If the healthcheck does not pass before the node timeout period is passed, the node is marked as being down. The default timings ensured this happened, which is distinctly suboptimal.
1 parent 9b1f2d7 commit 0795e78

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

java/server/src/org/openqa/selenium/grid/distributor/config/DistributorOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
public class DistributorOptions {
3333

34-
public static final int DEFAULT_HEALTHCHECK_INTERVAL = 300;
34+
public static final int DEFAULT_HEALTHCHECK_INTERVAL = 120;
3535
public static final String DISTRIBUTOR_SECTION = "distributor";
3636
static final String DEFAULT_DISTRIBUTOR_IMPLEMENTATION =
3737
"org.openqa.selenium.grid.distributor.local.LocalDistributor";

java/server/src/org/openqa/selenium/grid/distributor/local/LocalDistributor.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import org.openqa.selenium.grid.sessionmap.config.SessionMapOptions;
5959
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
6060
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions;
61+
import org.openqa.selenium.internal.Debug;
6162
import org.openqa.selenium.internal.Either;
6263
import org.openqa.selenium.internal.Require;
6364
import org.openqa.selenium.remote.SessionId;
@@ -249,8 +250,6 @@ private void register(NodeStatus status) {
249250
public LocalDistributor add(Node node) {
250251
Require.nonNull("Node", node);
251252

252-
LOG.info(String.format("Added node %s at %s.", node.getId(), node.getUri()));
253-
254253
nodes.put(node.getId(), node);
255254
model.add(node.getStatus());
256255

@@ -259,6 +258,12 @@ public LocalDistributor add(Node node) {
259258
allChecks.put(node.getId(), runnableHealthCheck);
260259
hostChecker.submit(runnableHealthCheck, healthcheckInterval, Duration.ofSeconds(30));
261260

261+
LOG.info(String.format(
262+
"Added node %s at %s. Health check every %ss",
263+
node.getId(),
264+
node.getUri(),
265+
healthcheckInterval.toMillis() / 1000));
266+
262267
bus.fire(new NodeAddedEvent(node.getId()));
263268

264269
return this;
@@ -268,6 +273,8 @@ private Runnable asRunnableHealthCheck(Node node) {
268273
HealthCheck healthCheck = node.getHealthCheck();
269274
NodeId id = node.getId();
270275
return () -> {
276+
LOG.log(getDebugLogLevel(), "Running health check for " + node.getId());
277+
271278
HealthCheck.Result result;
272279
try {
273280
result = healthCheck.check();
@@ -279,6 +286,9 @@ private Runnable asRunnableHealthCheck(Node node) {
279286
Lock writeLock = lock.writeLock();
280287
writeLock.lock();
281288
try {
289+
LOG.log(
290+
getDebugLogLevel(),
291+
String.format("Health check result for %s was %s", node.getId(), result.getAvailability()));
282292
model.setAvailability(id, result.getAvailability());
283293
} finally {
284294
writeLock.unlock();

0 commit comments

Comments
 (0)