Skip to content

Commit ecc30e4

Browse files
committed
[grid] Distributor should not add a Node if it is draining
1 parent e3d3da3 commit ecc30e4

1 file changed

Lines changed: 20 additions & 15 deletions

File tree

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

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,9 @@
1717

1818
package org.openqa.selenium.grid.distributor.local;
1919

20-
import static com.google.common.collect.ImmutableSet.toImmutableSet;
21-
import static org.openqa.selenium.grid.data.Availability.DOWN;
22-
import static org.openqa.selenium.grid.data.Availability.DRAINING;
23-
import static org.openqa.selenium.grid.data.Availability.UP;
24-
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
25-
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES;
26-
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES_EVENT;
27-
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
28-
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
29-
import static org.openqa.selenium.remote.tracing.AttributeKey.SESSION_URI;
30-
import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;
31-
3220
import com.google.common.collect.ImmutableMap;
3321
import com.google.common.collect.ImmutableSet;
3422

35-
import dev.failsafe.Failsafe;
36-
import dev.failsafe.RetryPolicy;
37-
3823
import org.openqa.selenium.Beta;
3924
import org.openqa.selenium.Capabilities;
4025
import org.openqa.selenium.HealthCheckFailedException;
@@ -91,6 +76,9 @@
9176
import org.openqa.selenium.remote.tracing.Tracer;
9277
import org.openqa.selenium.status.HasReadyState;
9378

79+
import dev.failsafe.Failsafe;
80+
import dev.failsafe.RetryPolicy;
81+
9482
import java.io.Closeable;
9583
import java.io.UncheckedIOException;
9684
import java.net.URI;
@@ -114,6 +102,18 @@
114102
import java.util.logging.Logger;
115103
import java.util.stream.Collectors;
116104

105+
import static com.google.common.collect.ImmutableSet.toImmutableSet;
106+
import static org.openqa.selenium.grid.data.Availability.DOWN;
107+
import static org.openqa.selenium.grid.data.Availability.DRAINING;
108+
import static org.openqa.selenium.grid.data.Availability.UP;
109+
import static org.openqa.selenium.internal.Debug.getDebugLogLevel;
110+
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES;
111+
import static org.openqa.selenium.remote.RemoteTags.CAPABILITIES_EVENT;
112+
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID;
113+
import static org.openqa.selenium.remote.RemoteTags.SESSION_ID_EVENT;
114+
import static org.openqa.selenium.remote.tracing.AttributeKey.SESSION_URI;
115+
import static org.openqa.selenium.remote.tracing.Tags.EXCEPTION;
116+
117117
public class LocalDistributor extends Distributor implements Closeable {
118118

119119
private static final Logger LOG = Logger.getLogger(LocalDistributor.class.getName());
@@ -303,6 +303,11 @@ public LocalDistributor add(Node node) {
303303
NodeStatus initialNodeStatus;
304304
try {
305305
initialNodeStatus = node.getStatus();
306+
if (initialNodeStatus.getAvailability() == DRAINING) {
307+
// A Node might be draining but the heartbeat is still running.
308+
// We do not need to add this Node again.
309+
return this;
310+
}
306311
model.add(initialNodeStatus);
307312
nodes.put(node.getId(), node);
308313
} catch (Exception e) {

0 commit comments

Comments
 (0)