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

Include stack trace in all gRPC errors when --verbose_failures is set. #16086

Closed
wants to merge 1 commit into from
Closed
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 @@ -507,7 +507,8 @@ public void beforeCommand(CommandEnvironment env) throws AbruptExitException {
}
} catch (IOException e) {
String errorMessage =
"Failed to query remote execution capabilities: " + Utils.grpcAwareErrorMessage(e);
"Failed to query remote execution capabilities: "
+ Utils.grpcAwareErrorMessage(e, verboseFailures);
if (remoteOptions.remoteLocalFallback) {
if (verboseFailures) {
errorMessage += System.lineSeparator() + Throwables.getStackTraceAsString(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,7 @@ public CacheHandle lookup(Spawn spawn, SpawnExecutionContext context)
if (BulkTransferException.isOnlyCausedByCacheNotFoundException(e)) {
// Intentionally left blank
} else {
String errorMessage;
if (!verboseFailures) {
errorMessage = Utils.grpcAwareErrorMessage(e);
} else {
// On --verbose_failures print the whole stack trace
errorMessage = "\n" + Throwables.getStackTraceAsString(e);
}
String errorMessage = Utils.grpcAwareErrorMessage(e, verboseFailures);
if (isNullOrEmpty(errorMessage)) {
errorMessage = e.getClass().getSimpleName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -566,11 +566,7 @@ private SpawnResult handleError(
catastrophe = false;
}

String errorMessage = Utils.grpcAwareErrorMessage(exception);
if (verboseFailures) {
// On --verbose_failures print the whole stack trace
errorMessage += "\n" + Throwables.getStackTraceAsString(exception);
}
String errorMessage = Utils.grpcAwareErrorMessage(exception, verboseFailures);

if (exception.getCause() instanceof ExecutionStatusException) {
ExecutionStatusException e = (ExecutionStatusException) exception.getCause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ private static String executionStatusExceptionErrorMessage(ExecutionStatusExcept
+ errorDetailsMessage(status.getDetailsList());
}

public static String grpcAwareErrorMessage(IOException e) {
private static String grpcAwareErrorMessage(IOException e) {
io.grpc.Status errStatus = io.grpc.Status.fromThrowable(e);
if (e.getCause() instanceof ExecutionStatusException) {
// Display error message returned by the remote service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,35 @@
public class UtilsTest {

@Test
public void testGrpcAwareErrorMessages() {
public void testGrpcAwareErrorMessage() {
IOException ioError = new IOException("io error");
IOException wrappedGrpcError =
new IOException(
"wrapped error", Status.ABORTED.withDescription("grpc error").asRuntimeException());

assertThat(Utils.grpcAwareErrorMessage(ioError)).isEqualTo("io error");
assertThat(Utils.grpcAwareErrorMessage(wrappedGrpcError)).isEqualTo("ABORTED: grpc error");
assertThat(Utils.grpcAwareErrorMessage(ioError, /* verboseFailures= */ false))
.isEqualTo("io error");
assertThat(Utils.grpcAwareErrorMessage(wrappedGrpcError, /* verboseFailures= */ false))
.isEqualTo("ABORTED: grpc error");
}

@Test
public void testGrpcAwareErrorMessage_verboseFailures() {
IOException ioError = new IOException("io error");
IOException wrappedGrpcError =
new IOException(
"wrapped error", Status.ABORTED.withDescription("grpc error").asRuntimeException());

assertThat(Utils.grpcAwareErrorMessage(ioError, /* verboseFailures= */ true))
.startsWith(
"io error\n"
+ "java.io.IOException: io error\n"
+ "\tat com.google.devtools.build.lib.remote.UtilsTest.testGrpcAwareErrorMessage_verboseFailures");
assertThat(Utils.grpcAwareErrorMessage(wrappedGrpcError, /* verboseFailures= */ true))
.startsWith(
"ABORTED: grpc error\n"
+ "java.io.IOException: wrapped error\n"
+ "\tat com.google.devtools.build.lib.remote.UtilsTest.testGrpcAwareErrorMessage_verboseFailures");
}

@Test
Expand Down