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

Print remote execution message when the action times out #15710

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 @@ -273,21 +273,7 @@ public SpawnResult exec(Spawn spawn, SpawnExecutionContext context)
// It's already late at this stage, but we should at least report once.
reporter.reportExecutingIfNot();

FileOutErr outErr = context.getFileOutErr();
String message = result.getMessage();
boolean printMessage =
((!result.success()
&& remoteOptions.remotePrintExecutionMessages
== ExecutionMessagePrintMode.FAILURE)
|| (result.success()
&& remoteOptions.remotePrintExecutionMessages
== ExecutionMessagePrintMode.SUCCESS)
|| remoteOptions.remotePrintExecutionMessages
== ExecutionMessagePrintMode.ALL)
&& !message.isEmpty();
if (printMessage) {
outErr.printErr(message + "\n");
}
maybePrintExecutionMessages(context, result.getMessage(), result.success());

profileAccounting(result.getExecutionMetadata());
spawnMetricsAccounting(spawnMetrics, result.getExecutionMetadata());
Expand Down Expand Up @@ -458,6 +444,16 @@ public boolean handlesCaching() {
return true;
}

private void maybePrintExecutionMessages(SpawnExecutionContext context, String message, boolean success) {
FileOutErr outErr = context.getFileOutErr();
boolean printMessage =
remoteOptions.remotePrintExecutionMessages.shouldPrintMessages(success)
&& !message.isEmpty();
if (printMessage) {
outErr.printErr(message + "\n");
}
}

private void maybeWriteParamFilesLocally(Spawn spawn) throws IOException {
if (!executionOptions.shouldMaterializeParamFiles()) {
return;
Expand Down Expand Up @@ -514,10 +510,10 @@ private SpawnResult execLocallyAndUploadOrFail(
if (remoteOptions.remoteLocalFallback && !RemoteRetrierUtils.causedByExecTimeout(cause)) {
return execLocallyAndUpload(action, spawn, context, uploadLocalResults);
}
return handleError(action, cause);
return handleError(action, cause, context);
}

private SpawnResult handleError(RemoteAction action, IOException exception)
private SpawnResult handleError(RemoteAction action, IOException exception, SpawnExecutionContext context)
throws ExecException, InterruptedException, IOException {
boolean remoteCacheFailed =
BulkTransferException.isOnlyCausedByCacheNotFoundException(exception);
Expand All @@ -536,6 +532,7 @@ private SpawnResult handleError(RemoteAction action, IOException exception)
}
}
if (e.isExecutionTimeout()) {
maybePrintExecutionMessages(context, e.getResponse().getMessage(), /* success = */ false);
return new SpawnResult.Builder()
.setRunnerName(getName())
.setStatus(Status.TIMEOUT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,5 +669,13 @@ public Converter() {
super(ExecutionMessagePrintMode.class, "execution message print mode");
}
}

public boolean shouldPrintMessages(boolean success) {
return ((!success
&& this == ExecutionMessagePrintMode.FAILURE)
|| (success
&& this == ExecutionMessagePrintMode.SUCCESS)
|| this == ExecutionMessagePrintMode.ALL);
}
}
}