Skip to content

Commit 20c084f

Browse files
committed
[grid] Covering use case where a Node is UP after being marked DOWN
Fixes #12116
1 parent a4d317d commit 20c084f

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

java/src/org/openqa/selenium/grid/distributor/GridModel.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,22 @@ public void refresh(NodeStatus status) {
178178
}
179179
}
180180

181-
public void touch(NodeId id) {
182-
Require.nonNull("Node ID", id);
181+
public void touch(NodeStatus nodeStatus) {
182+
Require.nonNull("Node ID", nodeStatus);
183183

184184
Lock writeLock = lock.writeLock();
185185
writeLock.lock();
186186
try {
187-
NodeStatus node = getNode(id);
187+
NodeStatus node = getNode(nodeStatus.getNodeId());
188188
if (node != null) {
189189
nodePurgeTimes.put(node.getNodeId(), Instant.now());
190+
// Covers the case where the Node might be DOWN in the Grid model (e.g. Node lost
191+
// connectivity for a while). The Node reports itself back as UP.
192+
if (node.getAvailability() != nodeStatus.getAvailability()
193+
&& nodeStatus.getAvailability() == UP) {
194+
nodes.remove(node);
195+
nodes.add(nodeStatus);
196+
}
190197
}
191198
} finally {
192199
writeLock.unlock();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public LocalDistributor(
205205
NodeHeartBeatEvent.listener(
206206
nodeStatus -> {
207207
if (nodes.containsKey(nodeStatus.getNodeId())) {
208-
model.touch(nodeStatus.getNodeId());
208+
model.touch(nodeStatus);
209209
} else {
210210
register(nodeStatus);
211211
}

0 commit comments

Comments
 (0)