Skip to content

Commit 336a0bf

Browse files
Merge branch 'trunk' into pallavi-getCookieRuby
2 parents 9f568ce + 4062023 commit 336a0bf

File tree

10 files changed

+136
-138
lines changed

10 files changed

+136
-138
lines changed

WORKSPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
66

77
http_archive(
88
name = "io_bazel_rules_closure",
9+
integrity = "sha256-lJjlc2jvuCuYXbHtQmp2fL8boDmP167WMvw5CGVOGx4=",
910
strip_prefix = "rules_closure-0.12.0",
1011
url = "https://github.com/bazelbuild/rules_closure/archive/refs/tags/0.12.0.tar.gz",
1112
)

java/src/org/openqa/selenium/grid/distributor/local/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@ java_library(
3131
"//java/src/org/openqa/selenium/json",
3232
"//java/src/org/openqa/selenium/remote",
3333
artifact("com.google.guava:guava"),
34-
artifact("dev.failsafe:failsafe"),
3534
],
3635
)

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

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
import com.google.common.annotations.VisibleForTesting;
3535
import com.google.common.collect.ImmutableMap;
3636
import com.google.common.collect.ImmutableSet;
37-
import dev.failsafe.Failsafe;
38-
import dev.failsafe.RetryPolicy;
3937
import java.io.Closeable;
4038
import java.io.UncheckedIOException;
4139
import java.net.URI;
@@ -375,7 +373,10 @@ public LocalDistributor add(Node node) {
375373
return this;
376374
}
377375

378-
updateNodeStatus(initialNodeStatus, healthCheck);
376+
updateNodeAvailability(
377+
initialNodeStatus.getExternalUri(),
378+
initialNodeStatus.getNodeId(),
379+
initialNodeStatus.getAvailability());
379380

380381
LOG.info(
381382
String.format(
@@ -387,30 +388,6 @@ public LocalDistributor add(Node node) {
387388
return this;
388389
}
389390

390-
private void updateNodeStatus(NodeStatus status, Runnable healthCheck) {
391-
// Setting the Node as available if the initial call to status was successful.
392-
// Otherwise, retry to have it available as soon as possible.
393-
if (status.getAvailability() == UP) {
394-
updateNodeAvailability(status.getExternalUri(), status.getNodeId(), status.getAvailability());
395-
} else {
396-
// Running the health check right after the Node registers itself. We retry the
397-
// execution because the Node might on a complex network topology. For example,
398-
// Kubernetes pods with IPs that take a while before they are reachable.
399-
RetryPolicy<Object> initialHealthCheckPolicy =
400-
RetryPolicy.builder()
401-
.withMaxAttempts(-1)
402-
.withMaxDuration(Duration.ofSeconds(90))
403-
.withDelay(Duration.ofSeconds(15))
404-
.abortIf(result -> true)
405-
.build();
406-
407-
LOG.log(getDebugLogLevel(), "Running health check for Node " + status.getExternalUri());
408-
ExecutorService executor = Executors.newSingleThreadExecutor();
409-
executor.submit(() -> Failsafe.with(initialHealthCheckPolicy).run(healthCheck::run));
410-
executor.shutdown();
411-
}
412-
}
413-
414391
private Runnable runNodeHealthChecks() {
415392
return () -> {
416393
ImmutableMap<NodeId, Runnable> nodeHealthChecks;

java/src/org/openqa/selenium/grid/node/Node.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.Map;
3333
import java.util.ServiceLoader;
3434
import java.util.Set;
35-
import java.util.UUID;
3635
import java.util.logging.Logger;
3736
import java.util.stream.Collectors;
3837
import java.util.stream.StreamSupport;
@@ -245,7 +244,7 @@ public TemporaryFilesystem getUploadsFilesystem(SessionId id) throws IOException
245244
throw new UnsupportedOperationException();
246245
}
247246

248-
public TemporaryFilesystem getDownloadsFilesystem(UUID uuid) throws IOException {
247+
public TemporaryFilesystem getDownloadsFilesystem(SessionId id) throws IOException {
249248
throw new UnsupportedOperationException();
250249
}
251250

java/src/org/openqa/selenium/grid/node/docker/DockerFlags.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ public class DockerFlags implements HasRoles {
5454
@ConfigValue(section = DockerOptions.DOCKER_SECTION, name = "port", example = "2375")
5555
private Integer dockerPort;
5656

57+
@Parameter(
58+
names = {"--docker-server-start-timeout"},
59+
description =
60+
"Max time (in seconds) to wait for the server to successfully start up, before cancelling"
61+
+ " the process.")
62+
@ConfigValue(
63+
section = DockerOptions.DOCKER_SECTION,
64+
name = "server-start-timeout",
65+
example = "55")
66+
private Integer serverStartTimeout;
67+
5768
@Parameter(
5869
names = {"--docker", "-D"},
5970
description =

java/src/org/openqa/selenium/grid/node/docker/DockerOptions.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.common.collect.Multimap;
2626
import java.net.URI;
2727
import java.net.URISyntaxException;
28+
import java.time.Duration;
2829
import java.util.ArrayList;
2930
import java.util.Arrays;
3031
import java.util.Collection;
@@ -63,6 +64,7 @@ public class DockerOptions {
6364
static final String DEFAULT_DOCKER_URL = "unix:/var/run/docker.sock";
6465
static final String DEFAULT_VIDEO_IMAGE = "false";
6566
static final int DEFAULT_MAX_SESSIONS = Runtime.getRuntime().availableProcessors();
67+
static final int DEFAULT_SERVER_START_TIMEOUT = 60;
6668
private static final String DEFAULT_DOCKER_NETWORK = "bridge";
6769
private static final Logger LOG = Logger.getLogger(DockerOptions.class.getName());
6870
private static final Json JSON = new Json();
@@ -104,6 +106,11 @@ private URI getDockerUri() {
104106
}
105107
}
106108

109+
private Duration getServerStartTimeout() {
110+
return Duration.ofSeconds(
111+
config.getInt(DOCKER_SECTION, "server-start-timeout").orElse(DEFAULT_SERVER_START_TIMEOUT));
112+
}
113+
107114
private boolean isEnabled(Docker docker) {
108115
if (!config.getAll(DOCKER_SECTION, "configs").isPresent()) {
109116
return false;
@@ -179,6 +186,7 @@ public Map<Capabilities, Collection<SessionFactory>> getDockerSessionFactories(
179186
tracer,
180187
clientFactory,
181188
options.getSessionTimeout(),
189+
getServerStartTimeout(),
182190
docker,
183191
getDockerUri(),
184192
image,

java/src/org/openqa/selenium/grid/node/docker/DockerSessionFactory.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public class DockerSessionFactory implements SessionFactory {
9191
private final Tracer tracer;
9292
private final HttpClient.Factory clientFactory;
9393
private final Duration sessionTimeout;
94+
private final Duration serverStartTimeout;
9495
private final Docker docker;
9596
private final URI dockerUri;
9697
private final Image browserImage;
@@ -108,6 +109,7 @@ public DockerSessionFactory(
108109
Tracer tracer,
109110
HttpClient.Factory clientFactory,
110111
Duration sessionTimeout,
112+
Duration serverStartTimeout,
111113
Docker docker,
112114
URI dockerUri,
113115
Image browserImage,
@@ -123,6 +125,7 @@ public DockerSessionFactory(
123125
this.tracer = Require.nonNull("Tracer", tracer);
124126
this.clientFactory = Require.nonNull("HTTP client", clientFactory);
125127
this.sessionTimeout = Require.nonNull("Session timeout", sessionTimeout);
128+
this.serverStartTimeout = Require.nonNull("Server start timeout", serverStartTimeout);
126129
this.docker = Require.nonNull("Docker command", docker);
127130
this.dockerUri = Require.nonNull("Docker URI", dockerUri);
128131
this.browserImage = Require.nonNull("Docker browser image", browserImage);
@@ -181,7 +184,7 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
181184
"Waiting for server to start (container id: %s, url %s)",
182185
container.getId(), remoteAddress));
183186
try {
184-
waitForServerToStart(client, Duration.ofMinutes(1));
187+
waitForServerToStart(client, serverStartTimeout);
185188
} catch (TimeoutException e) {
186189
span.setAttribute(AttributeKey.ERROR.getKey(), true);
187190
span.setStatus(Status.CANCELLED);
@@ -367,7 +370,7 @@ private Container startVideoContainer(
367370
clientFactory.createClient(ClientConfig.defaultConfig().baseUri(videoContainerUrl));
368371
try {
369372
LOG.fine(String.format("Waiting for video recording... (id: %s)", videoContainer.getId()));
370-
waitForServerToStart(videoClient, Duration.ofMinutes(1));
373+
waitForServerToStart(videoClient, serverStartTimeout);
371374
} catch (Exception e) {
372375
videoContainer.stop(Duration.ofSeconds(10));
373376
String message =

0 commit comments

Comments
 (0)