aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2018-03-29 14:59:43 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-29 15:01:36 -0700
commit8fd53fba63971f58beab889dd4f3d46726dde672 (patch)
tree2d084a99ec134f36846537ba9009a0e0b1218078 /src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
parenta29da01b360b778d15ed735222d0f1d247954acf (diff)
This change adds the writing of the remote execution log to a file behind an experimental flag. It also adds a logging handler for Execute calls so that they are logged.
PiperOrigin-RevId: 190991493
Diffstat (limited to 'src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java')
-rw-r--r--src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
index dbb0e063b4..805f8f24ae 100644
--- a/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
+++ b/src/main/java/com/google/devtools/build/lib/remote/RemoteModule.java
@@ -22,6 +22,7 @@ import com.google.devtools.build.lib.buildeventstream.PathConverter;
import com.google.devtools.build.lib.buildtool.BuildRequest;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.exec.ExecutorBuilder;
+import com.google.devtools.build.lib.remote.logging.LoggingInterceptor;
import com.google.devtools.build.lib.remote.util.DigestUtil;
import com.google.devtools.build.lib.runtime.BlazeModule;
import com.google.devtools.build.lib.runtime.Command;
@@ -29,6 +30,7 @@ import com.google.devtools.build.lib.runtime.CommandEnvironment;
import com.google.devtools.build.lib.runtime.ServerBuilder;
import com.google.devtools.build.lib.util.AbruptExitException;
import com.google.devtools.build.lib.util.ExitCode;
+import com.google.devtools.build.lib.util.io.AsynchronousFileOutputStream;
import com.google.devtools.build.lib.vfs.FileSystem.HashFunction;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
@@ -36,12 +38,14 @@ import com.google.devtools.common.options.OptionsBase;
import com.google.devtools.common.options.OptionsProvider;
import com.google.devtools.remoteexecution.v1test.Digest;
import io.grpc.Channel;
+import io.grpc.ClientInterceptors;
import java.io.IOException;
import java.util.logging.Logger;
/** RemoteModule provides distributed cache and remote execution for Bazel. */
public final class RemoteModule extends BlazeModule {
private static final Logger logger = Logger.getLogger(RemoteModule.class.getName());
+ private AsynchronousFileOutputStream rpcLogFile;
@VisibleForTesting
static final class CasPathConverter implements PathConverter {
@@ -126,6 +130,10 @@ public final class RemoteModule extends BlazeModule {
boolean remoteOrLocalCache = SimpleBlobStoreFactory.isRemoteCacheOptions(remoteOptions);
boolean grpcCache = GrpcRemoteCache.isRemoteCacheOptions(remoteOptions);
+ if (!remoteOptions.experimentalRemoteGrpcLog.isEmpty()) {
+ rpcLogFile = new AsynchronousFileOutputStream(remoteOptions.experimentalRemoteGrpcLog);
+ }
+
RemoteRetrier retrier =
new RemoteRetrier(
remoteOptions, RemoteRetrier.RETRIABLE_GRPC_ERRORS, Retrier.ALLOW_ALL_CALLS);
@@ -157,9 +165,13 @@ public final class RemoteModule extends BlazeModule {
final GrpcRemoteExecutor executor;
if (remoteOptions.remoteExecutor != null) {
+ Channel ch = GoogleAuthUtils.newChannel(remoteOptions.remoteExecutor, authAndTlsOptions);
+ if (rpcLogFile != null) {
+ ch = ClientInterceptors.intercept(ch, new LoggingInterceptor(rpcLogFile));
+ }
executor =
new GrpcRemoteExecutor(
- GoogleAuthUtils.newChannel(remoteOptions.remoteExecutor, authAndTlsOptions),
+ ch,
GoogleAuthUtils.newCallCredentials(authAndTlsOptions),
remoteOptions.remoteTimeout,
retrier);
@@ -176,6 +188,19 @@ public final class RemoteModule extends BlazeModule {
}
@Override
+ public void afterCommand() {
+ if (rpcLogFile != null) {
+ try {
+ rpcLogFile.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } finally {
+ rpcLogFile = null;
+ }
+ }
+ }
+
+ @Override
public void executorInit(CommandEnvironment env, BuildRequest request, ExecutorBuilder builder) {
if (actionContextProvider != null) {
builder.addActionContextProvider(actionContextProvider);