Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.testcontainers.utility;

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

CountDownLatch ryukScheduledLatch = new CountDownLatch(1);
AtomicReference<IOException> lastConnectException = new AtomicReference<>();

String host = ryukContainer.getHost();
Integer ryukPort = ryukContainer.getFirstMappedPort();
Expand Down Expand Up @@ -117,7 +119,12 @@ private synchronized void maybeStart() {
}
}
} catch (IOException e) {
log.warn("Can not connect to Ryuk at {}:{}", host, ryukPort, e);
if (ryukScheduledLatch.getCount() != 0) {
log.debug(CANNOT_CONNECT, host, ryukPort, e);
lastConnectException.set(e);
} else {
log.warn(CANNOT_CONNECT, host, ryukPort, e);
}
}
});
}
Expand All @@ -129,7 +136,10 @@ private synchronized void maybeStart() {
// We need to wait before we can start any containers to make sure that we delete them
if (!ryukScheduledLatch.await(TestcontainersConfiguration.getInstance().getRyukTimeout(), TimeUnit.SECONDS)) {
log.error("Timed out waiting for Ryuk container to start. Ryuk's logs:\n{}", ryukContainer.getLogs());
throw new IllegalStateException(String.format("Could not connect to Ryuk at %s:%s", host, ryukPort));
throw new IllegalStateException(String.format("Could not connect to Ryuk at %s:%s", host, ryukPort),
lastConnectException.get());
}
}

private static final String CANNOT_CONNECT = "Cannot connect to Ryuk at {}:{}";
}