Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure we don't hide exceptions from waitUntilContainerStarted #6167

Merged
Show file tree
Hide file tree
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
Expand Up @@ -493,25 +493,31 @@ private void tryStart(Instant startedAt) {
}

if (inspectContainerResponse == null) {
throw new IllegalStateException("Container is removed");
throw new IllegalStateException("Wait strategy failed. Container is removed", e);
}

InspectContainerResponse.ContainerState state = inspectContainerResponse.getState();
if (Boolean.TRUE.equals(state.getDead())) {
throw new IllegalStateException("Container is dead");
throw new IllegalStateException("Wait strategy failed. Container is dead", e);
}

if (Boolean.TRUE.equals(state.getOOMKilled())) {
throw new IllegalStateException("Container crashed with out-of-memory (OOMKilled)");
throw new IllegalStateException(
"Wait strategy failed. Container crashed with out-of-memory (OOMKilled)",
e
);
}

String error = state.getError();
if (!StringUtils.isBlank(error)) {
throw new IllegalStateException("Container crashed: " + error);
throw new IllegalStateException("Wait strategy failed. Container crashed: " + error, e);
}

if (!Boolean.TRUE.equals(state.getRunning())) {
throw new IllegalStateException("Container exited with code " + state.getExitCode());
throw new IllegalStateException(
"Wait strategy failed. Container exited with code " + state.getExitCode(),
e
);
}

throw e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ public void shouldReportOOMAfterWait() {
})
.withCommand("sh", "-c", "A='0123456789'; for i in $(seq 0 32); do A=$A$A; done; sleep 10m")
) {
assertThatThrownBy(container::start).hasStackTraceContaining("Container crashed with out-of-memory");
assertThatThrownBy(container::start)
.hasStackTraceContaining("Wait strategy failed. Container crashed with out-of-memory (OOMKilled)")
.hasStackTraceContaining("Nope!");
}
}

Expand All @@ -67,7 +69,9 @@ public void shouldReportErrorAfterWait() {
.waitingFor(new WaitForExitedState(state -> state.getExitCode() > 0))
.withCommand("sh", "-c", "usleep 100; exit 123")
) {
assertThatThrownBy(container::start).hasStackTraceContaining("Container exited with code 123");
assertThatThrownBy(container::start)
.hasStackTraceContaining("Wait strategy failed. Container exited with code 123")
.hasStackTraceContaining("Nope!");
}
}

Expand All @@ -80,7 +84,9 @@ public void shouldCopyTransferableAsFile() {
.waitingFor(new WaitForExitedState(state -> state.getExitCodeLong() > 0))
.withCommand("sh", "-c", "grep -q test /tmp/test && exit 100")
) {
assertThatThrownBy(container::start).hasStackTraceContaining("Container exited with code 100");
assertThatThrownBy(container::start)
.hasStackTraceContaining("Wait strategy failed. Container exited with code 100")
.hasStackTraceContaining("Nope!");
}
}

Expand All @@ -93,7 +99,9 @@ public void shouldCopyTransferableAsFileWithFileMode() {
.waitingFor(new WaitForExitedState(state -> state.getExitCodeLong() > 0))
.withCommand("sh", "-c", "ls -ll /tmp | grep '\\-rwxrwxrwx\\|test' && exit 100")
) {
assertThatThrownBy(container::start).hasStackTraceContaining("Container exited with code 100");
assertThatThrownBy(container::start)
.hasStackTraceContaining("Wait strategy failed. Container exited with code 100")
.hasStackTraceContaining("Nope!");
}
}

Expand All @@ -107,7 +115,9 @@ public void shouldCopyTransferableAfterMountableFile() {
.waitingFor(new WaitForExitedState(state -> state.getExitCodeLong() > 0))
.withCommand("sh", "-c", "grep -q test /tmp/test && exit 100")
) {
assertThatThrownBy(container::start).hasStackTraceContaining("Container exited with code 100");
assertThatThrownBy(container::start)
.hasStackTraceContaining("Wait strategy failed. Container exited with code 100")
.hasStackTraceContaining("Nope!");
}
}

Expand Down