Skip to content

Commit 3c30a26

Browse files
vincz7777bsideupVincent MIJOULE (contractor)rnorth
authored
Display Ryuk logs when it fails to start (#4842)
Co-authored-by: Sergei Egorov <[email protected]> Co-authored-by: Vincent MIJOULE (contractor) <[email protected]> Co-authored-by: Richard North <[email protected]>
1 parent e597f4a commit 3c30a26

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

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

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import java.net.Socket;
3535
import java.net.URLEncoder;
3636
import java.nio.charset.StandardCharsets;
37-
import java.time.Duration;
3837
import java.util.AbstractMap.SimpleEntry;
3938
import java.util.ArrayList;
4039
import java.util.Collections;
@@ -133,25 +132,31 @@ public void onNext(Frame frame) {
133132
}
134133
});
135134

136-
ContainerState containerState = new ContainerState() {
137-
135+
InspectContainerResponse inspectedContainer;
136+
try {
138137
// inspect container response might initially not contain the mapped port
139-
final InspectContainerResponse inspectedContainer = await()
138+
inspectedContainer = await()
140139
.atMost(5, TimeUnit.SECONDS)
141140
.pollInterval(DynamicPollInterval.ofMillis(50))
142141
.pollInSameThread()
143142
.until(
144143
() -> client.inspectContainerCmd(ryukContainerId).exec(),
145144
inspectContainerResponse -> {
146145
return inspectContainerResponse
147-
.getNetworkSettings()
148-
.getPorts()
149-
.getBindings()
150-
.values()
151-
.stream()
152-
.anyMatch(Objects::nonNull);
146+
.getNetworkSettings()
147+
.getPorts()
148+
.getBindings()
149+
.values()
150+
.stream()
151+
.anyMatch(Objects::nonNull);
153152
}
154153
);
154+
} catch (Exception e) {
155+
log.warn("Ryuk container cannot be inspected and probably had a problem starting. Ryuk's logs:\n{}", ryukLog);
156+
throw new IllegalStateException("Ryuk failed to start", e);
157+
}
158+
159+
ContainerState containerState = new ContainerState() {
155160

156161
@Override
157162
public List<Integer> getExposedPorts() {

0 commit comments

Comments
 (0)