From 0578a6042a84b48a5397aa0e5762db6751dde533 Mon Sep 17 00:00:00 2001 From: Samuel Souza Date: Wed, 21 Mar 2018 11:47:00 +0000 Subject: [PATCH] Add logging to native health check We fail after 2 minutes when checking the native health check. This might not be enough time to have all the docker containers up. We can configure the timeout, but it was quite hard to debug this without logging. --- .../compose/connection/waiting/ClusterHealthCheck.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterHealthCheck.java b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterHealthCheck.java index 5f2cbbf27..96e97b410 100644 --- a/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterHealthCheck.java +++ b/docker-compose-rule-core/src/main/java/com/palantir/docker/compose/connection/waiting/ClusterHealthCheck.java @@ -25,9 +25,13 @@ import java.util.List; import java.util.Set; import java.util.function.Function; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @FunctionalInterface public interface ClusterHealthCheck { + Logger log = LoggerFactory.getLogger(ClusterHealthCheck.class); + static ClusterHealthCheck serviceHealthCheck(List containerNames, HealthCheck> delegate) { return transformingHealthCheck(cluster -> cluster.containers(containerNames), delegate); } @@ -52,13 +56,18 @@ static ClusterHealthCheck nativeHealthChecks() { return cluster -> { Set unhealthyContainers = new LinkedHashSet<>(); try { + log.info("Checking health of containers {}", + cluster.allContainers().stream().map(Container::toString).collect(joining(", "))); for (Container container : cluster.allContainers()) { + log.info("Checking health of container {}", container); State state = container.state(); if (state == State.UNHEALTHY) { + log.info("Container unhealthy {}", container); unhealthyContainers.add(container.getContainerName()); } } if (!unhealthyContainers.isEmpty()) { + log.warn("Unhealthy containers {}", unhealthyContainers.stream().collect(joining(", "))); return SuccessOrFailure.failure( "The following containers are not healthy: " + unhealthyContainers.stream().collect(joining(", "))); }