Skip to content

Commit 56a9743

Browse files
committed
RyukResourceReaper log initial expected errors at debug
1 parent 63189c8 commit 56a9743

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

core/src/main/java/org/testcontainers/utility/RyukResourceReaper.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.testcontainers.utility;
22

33
import com.github.dockerjava.api.command.CreateContainerCmd;
4+
import java.util.concurrent.atomic.AtomicReference;
45
import lombok.SneakyThrows;
56
import lombok.extern.slf4j.Slf4j;
67
import org.rnorth.ducttape.ratelimits.RateLimiter;
@@ -78,6 +79,7 @@ private synchronized void maybeStart() {
7879
ryukContainer.start();
7980

8081
CountDownLatch ryukScheduledLatch = new CountDownLatch(1);
82+
AtomicReference<IOException> lastConnectException = new AtomicReference<>();
8183

8284
String host = ryukContainer.getHost();
8385
Integer ryukPort = ryukContainer.getFirstMappedPort();
@@ -117,7 +119,12 @@ private synchronized void maybeStart() {
117119
}
118120
}
119121
} catch (IOException e) {
120-
log.warn("Can not connect to Ryuk at {}:{}", host, ryukPort, e);
122+
if (ryukScheduledLatch.getCount() != 0) {
123+
log.debug(CANNOT_CONNECT, host, ryukPort, e);
124+
lastConnectException.set(e);
125+
} else {
126+
log.warn(CANNOT_CONNECT, host, ryukPort, e);
127+
}
121128
}
122129
});
123130
}
@@ -129,7 +136,10 @@ private synchronized void maybeStart() {
129136
// We need to wait before we can start any containers to make sure that we delete them
130137
if (!ryukScheduledLatch.await(TestcontainersConfiguration.getInstance().getRyukTimeout(), TimeUnit.SECONDS)) {
131138
log.error("Timed out waiting for Ryuk container to start. Ryuk's logs:\n{}", ryukContainer.getLogs());
132-
throw new IllegalStateException(String.format("Could not connect to Ryuk at %s:%s", host, ryukPort));
139+
throw new IllegalStateException(String.format("Could not connect to Ryuk at %s:%s", host, ryukPort),
140+
lastConnectException.get());
133141
}
134142
}
143+
144+
private static final String CANNOT_CONNECT = "Cannot connect to Ryuk at {}:{}";
135145
}

0 commit comments

Comments
 (0)