Skip to content

Commit

Permalink
add --experimental_remote_execute_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
luxe committed Oct 8, 2020
1 parent 642a800 commit 5dd1fb5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.Iterator;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;

/** A remote work executor that uses gRPC for communicating the work, inputs and outputs. */
Expand All @@ -57,9 +58,13 @@ public GrpcRemoteExecutor(
}

private ExecutionBlockingStub execBlockingStub() {
return ExecutionGrpc.newBlockingStub(channel)
ExecutionBlockingStub stub = ExecutionGrpc.newBlockingStub(channel)
.withInterceptors(TracingMetadataUtils.attachMetadataFromContextInterceptor())
.withCallCredentials(callCredentials);
if (options.remoteExecuteTimeout != null){
stub = stub.withDeadlineAfter(options.remoteExecuteTimeout.getSeconds(), TimeUnit.SECONDS);
}
return stub;
}

private void handleStatus(Status statusProto, @Nullable ExecuteResponse resp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,19 @@ public final class RemoteOptions extends OptionsBase {
+ " the unit is omitted, the value is interpreted as seconds.")
public Duration remoteTimeout;

@Option(
name = "experimental_remote_execute_timeout",
defaultValue = "null",
documentationCategory = OptionDocumentationCategory.REMOTE,
effectTags = {OptionEffectTag.UNKNOWN},
converter = RemoteTimeoutConverter.class,
help =
"The maximum amount of time to wait for remote execution's execute response"
+ " Following units can be"
+ " used: Days (d), hours (h), minutes (m), seconds (s), and milliseconds (ms). If"
+ " the unit is omitted, the value is interpreted as seconds.")
public Duration remoteExecuteTimeout;

/** Returns the specified duration. Assumes seconds if unitless. */
public static class RemoteTimeoutConverter implements Converter<Duration> {
private static final Pattern UNITLESS_REGEX = Pattern.compile("^[0-9]+$");
Expand Down

0 comments on commit 5dd1fb5

Please sign in to comment.