Skip to content

Commit

Permalink
[grid] Reducing log output for Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Mar 19, 2021
1 parent b58c848 commit f0ca78c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
6 changes: 3 additions & 3 deletions java/server/src/org/openqa/selenium/docker/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ContainerId getId() {
}

public void start() {
LOG.info("Starting " + getId());
LOG.info("Starting container " + getId());
protocol.startContainer(id);
this.running = true;
}
Expand All @@ -52,7 +52,7 @@ public void stop(Duration timeout) {
Require.nonNull("Timeout to wait for", timeout);

if (this.running) {
LOG.info("Stopping " + getId());
LOG.info("Stopping container " + getId());
try {
protocol.stopContainer(id, timeout);
this.running = false;
Expand All @@ -63,7 +63,7 @@ public void stop(Duration timeout) {
}

public ContainerInfo inspect() {
LOG.info("Inspecting " + getId());
LOG.info("Inspecting container " + getId());

return protocol.inspectContainer(getId());
}
Expand Down
4 changes: 2 additions & 2 deletions java/server/src/org/openqa/selenium/docker/Docker.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Image getImage(String name) {
public Container create(ContainerConfig config) {
Require.nonNull("Container config", config);

LOG.info("Creating image from " + config);
LOG.fine("Creating image from " + config);

return getDocker()
.map(protocol -> protocol.create(config))
Expand All @@ -65,7 +65,7 @@ public Container create(ContainerConfig config) {
public Optional<ContainerInfo> inspect(ContainerId id) {
Require.nonNull("Container id", id);

LOG.info("Inspecting container with id: " + id);
LOG.fine("Inspecting container with id: " + id);

if (!getDocker().map(protocol -> protocol.isContainerPresent(id)).orElse(false)) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.openqa.selenium.docker.v1_40;

import org.openqa.selenium.docker.Container;
import org.openqa.selenium.docker.ContainerId;
import org.openqa.selenium.docker.ContainerConfig;
import org.openqa.selenium.docker.ContainerId;
import org.openqa.selenium.docker.DockerException;
import org.openqa.selenium.docker.DockerProtocol;
import org.openqa.selenium.internal.Require;
Expand Down Expand Up @@ -69,11 +69,15 @@ public Container apply(ContainerConfig info) {
ContainerId id = new ContainerId((String) rawContainer.get("Id"));

if (rawContainer.get("Warnings") instanceof Collection) {
String allWarnings = ((Collection<?>) rawContainer.get("Warnings")).stream()
.map(String::valueOf)
.collect(Collectors.joining("\n", " * ", ""));
Collection<?> warnings = (Collection<?>) rawContainer.get("Warnings");
if (warnings.size() > 0) {
String allWarnings = warnings.stream()
.map(String::valueOf)
.collect(Collectors.joining("\n", " * ", ""));

LOG.info(String.format("Warnings while creating %s from %s: %s", id, info, allWarnings));
LOG.warning(
String.format("Warnings while creating %s from %s: %s", id, info, allWarnings));
}
}

return new Container(protocol, id);
Expand Down
10 changes: 5 additions & 5 deletions java/server/src/org/openqa/selenium/docker/v1_40/V140Docker.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package org.openqa.selenium.docker.v1_40;

import org.openqa.selenium.docker.Container;
import org.openqa.selenium.docker.ContainerId;
import org.openqa.selenium.docker.ContainerConfig;
import org.openqa.selenium.docker.ContainerId;
import org.openqa.selenium.docker.ContainerInfo;
import org.openqa.selenium.docker.ContainerLogs;
import org.openqa.selenium.docker.DockerException;
Expand Down Expand Up @@ -91,7 +91,7 @@ public Image getImage(String imageName) throws DockerException {
public Container create(ContainerConfig config) {
Require.nonNull("Container config", config);

LOG.info("Creating container: " + config);
LOG.fine("Creating container: " + config);

return createContainer.apply(config);
}
Expand All @@ -109,7 +109,7 @@ public boolean isContainerPresent(ContainerId id) throws DockerException {
public void startContainer(ContainerId id) throws DockerException {
Require.nonNull("Container id", id);

LOG.info("Starting container: " + id);
LOG.fine("Starting container: " + id);

startContainer.apply(id);
}
Expand All @@ -119,7 +119,7 @@ public void stopContainer(ContainerId id, Duration timeout) throws DockerExcepti
Require.nonNull("Container id", id);
Require.nonNull("Timeout", timeout);

LOG.info("Stopping container: " + id);
LOG.fine("Stopping container: " + id);

stopContainer.apply(id, timeout);
}
Expand All @@ -128,7 +128,7 @@ public void stopContainer(ContainerId id, Duration timeout) throws DockerExcepti
public ContainerInfo inspectContainer(ContainerId id) throws DockerException {
Require.nonNull("Container id", id);

LOG.info("Inspecting container: " + id);
LOG.fine("Inspecting container: " + id);

return inspectContainer.apply(id);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ public Either<WebDriverException, ActiveSession> apply(CreateSessionRequest sess
attributeMap.put("container.ip", EventAttribute.setValue(containerInfo.getIp()));
attributeMap.put("docker.server.url", EventAttribute.setValue(remoteAddress.toString()));

LOG.info(String.format("Waiting for server to start (container id: %s)", container.getId()));
LOG.info(
String.format("Waiting for server to start (container id: %s, url %s)",
container.getId(),
remoteAddress));
try {
waitForServerToStart(client, Duration.ofMinutes(1));
} catch (TimeoutException e) {
Expand Down

0 comments on commit f0ca78c

Please sign in to comment.