Skip to content
Open
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 @@ -76,7 +76,8 @@ public static ManagedChannel newChannel(
String target,
String proxy,
AuthAndTLSOptions options,
@Nullable List<ClientInterceptor> interceptors)
@Nullable List<ClientInterceptor> interceptors,
@Nullable Map<String, ?> serviceConfig)
throws IOException {
Preconditions.checkNotNull(target);
Preconditions.checkNotNull(options);
Expand Down Expand Up @@ -133,6 +134,10 @@ public static ManagedChannel newChannel(
if (interceptors != null) {
builder.intercept(interceptors);
}
if (serviceConfig != null) {
builder.disableServiceConfigLookUp();
builder.defaultServiceConfig(serviceConfig);
}
if (sslContext != null) {
builder.sslContext(sslContext);
if (options.tlsAuthorityOverride != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ protected ManagedChannel newGrpcChannel(BackendConfig config) throws IOException
config.besBackend(),
config.besProxy(),
config.authAndTLSOptions(),
/* interceptors= */ null);
/* interceptors= */ null,
/* serviceConfig= */ null);
}

@Override
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/google/devtools/build/lib/remote/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ java_library(
"//third_party:auth",
"//third_party:caffeine",
"//third_party:flogger",
"//third_party:gson",
"//third_party:guava",
"//third_party:jsr305",
"//third_party:netty",
Expand All @@ -169,6 +170,7 @@ java_library(
"@googleapis//google/bytestream:bytestream_java_proto",
"@googleapis//google/longrunning:longrunning_java_proto",
"@googleapis//google/rpc:rpc_java_proto",
"@remoteapis//:build_bazel_remote_asset_v1_remote_asset_java_grpc",
"@remoteapis//:build_bazel_remote_execution_v2_remote_execution_java_grpc",
"@remoteapis//:build_bazel_remote_execution_v2_remote_execution_java_proto",
"@remoteapis//:build_bazel_semver_semver_java_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
// limitations under the License.
package com.google.devtools.build.lib.remote;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.util.concurrent.Futures.immediateVoidFuture;
import static com.google.devtools.build.lib.remote.util.DigestUtil.isOldStyleDigestFunction;
import static java.lang.String.format;
import static java.util.concurrent.TimeUnit.SECONDS;

import build.bazel.remote.execution.v2.Digest;
import build.bazel.remote.execution.v2.DigestFunction;
Expand Down Expand Up @@ -65,7 +63,6 @@ final class ByteStreamUploader {
private final String instanceName;
private final ReferenceCountedChannel channel;
private final CallCredentialsProvider callCredentialsProvider;
private final long callTimeoutSecs;
private final RemoteRetrier retrier;
private final DigestFunction.Value digestFunction;
private final AtomicBoolean queryWriteStatusImplemented = new AtomicBoolean(true);
Expand All @@ -79,23 +76,18 @@ final class ByteStreamUploader {
* call. See the {@code ByteStream} service definition for details
* @param channel the {@link io.grpc.Channel} to use for calls
* @param callCredentialsProvider the credentials provider to use for authentication.
* @param callTimeoutSecs the timeout in seconds after which a {@code Write} gRPC call must be
* complete. The timeout resets between retries
* @param retrier the {@link RemoteRetrier} whose backoff strategy to use for retry timings.
*/
ByteStreamUploader(
@Nullable String instanceName,
ReferenceCountedChannel channel,
CallCredentialsProvider callCredentialsProvider,
long callTimeoutSecs,
RemoteRetrier retrier,
int maximumOpenFiles,
DigestFunction.Value digestFunction) {
checkArgument(callTimeoutSecs > 0, "callTimeoutSecs must be gt 0.");
this.instanceName = instanceName;
this.channel = channel;
this.callCredentialsProvider = callCredentialsProvider;
this.callTimeoutSecs = callTimeoutSecs;
this.retrier = retrier;
this.openedFilePermits = maximumOpenFiles != -1 ? new Semaphore(maximumOpenFiles) : null;
this.digestFunction = digestFunction;
Expand Down Expand Up @@ -180,14 +172,7 @@ private ListenableFuture<Void> startAsyncUpload(
}
}
AsyncUpload newUpload =
new AsyncUpload(
context,
channel,
callCredentialsProvider,
callTimeoutSecs,
retrier,
resourceName,
chunker);
new AsyncUpload(context, channel, callCredentialsProvider, retrier, resourceName, chunker);
ListenableFuture<Void> currUpload = newUpload.start();
currUpload.addListener(
() -> {
Expand All @@ -213,7 +198,6 @@ private final class AsyncUpload implements AsyncCallable<Long> {
private final RemoteActionExecutionContext context;
private final ReferenceCountedChannel channel;
private final CallCredentialsProvider callCredentialsProvider;
private final long callTimeoutSecs;
private final Retrier retrier;
private final String resourceName;
private final Chunker chunker;
Expand All @@ -225,14 +209,12 @@ private final class AsyncUpload implements AsyncCallable<Long> {
RemoteActionExecutionContext context,
ReferenceCountedChannel channel,
CallCredentialsProvider callCredentialsProvider,
long callTimeoutSecs,
Retrier retrier,
String resourceName,
Chunker chunker) {
this.context = context;
this.channel = channel;
this.callCredentialsProvider = callCredentialsProvider;
this.callTimeoutSecs = callTimeoutSecs;
this.retrier = retrier;
this.progressiveBackoff = new ProgressiveBackoff(retrier::newBackoff);
this.resourceName = resourceName;
Expand Down Expand Up @@ -314,16 +296,14 @@ private ByteStreamFutureStub bsFutureStub(Channel channel) {
return ByteStreamGrpc.newFutureStub(channel)
.withInterceptors(
TracingMetadataUtils.attachMetadataInterceptor(context.getRequestMetadata()))
.withCallCredentials(callCredentialsProvider.getCallCredentials())
.withDeadlineAfter(callTimeoutSecs, SECONDS);
.withCallCredentials(callCredentialsProvider.getCallCredentials());
}

private ByteStreamStub bsAsyncStub(Channel channel) {
return ByteStreamGrpc.newStub(channel)
.withInterceptors(
TracingMetadataUtils.attachMetadataInterceptor(context.getRequestMetadata()))
.withCallCredentials(callCredentialsProvider.getCallCredentials())
.withDeadlineAfter(callTimeoutSecs, SECONDS);
.withCallCredentials(callCredentialsProvider.getCallCredentials());
}

private ListenableFuture<Long> query() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
import io.grpc.ManagedChannel;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/** A factory interface for creating a {@link ManagedChannel}. */
public interface ChannelFactory {
ManagedChannel newChannel(
String target, String proxy, AuthAndTLSOptions options, List<ClientInterceptor> interceptors)
String target,
String proxy,
AuthAndTLSOptions options,
List<ClientInterceptor> interceptors,
Map<String, ?> serviceConfig)
throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import io.reactivex.rxjava3.core.Single;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;

Expand All @@ -61,6 +62,7 @@ public class GoogleChannelConnectionFactory
private final Reporter reporter;
@Nullable private final RemoteServerCapabilities remoteServerCapabilities;
private final RemoteOptions remoteOptions;
private final Map<String, ?> serviceConfig;
private final DigestFunction.Value digestFunction;
private final ServerCapabilitiesRequirement requirement;

Expand All @@ -69,6 +71,7 @@ public GoogleChannelConnectionFactory(
String target,
String proxy,
RemoteOptions remoteOptions,
Map<String, ?> serviceConfig,
AuthAndTLSOptions options,
List<ClientInterceptor> interceptors,
int maxConcurrency,
Expand All @@ -91,14 +94,15 @@ public GoogleChannelConnectionFactory(
this.reporter = reporter;
this.remoteServerCapabilities = remoteServerCapabilities;
this.remoteOptions = remoteOptions;
this.serviceConfig = serviceConfig;
this.digestFunction = digestFunction;
this.requirement = requirement;
}

@Override
public Single<ChannelConnectionWithServerCapabilities> create() {
return Single.fromCallable(
() -> channelFactory.newChannel(target, proxy, options, interceptors))
() -> channelFactory.newChannel(target, proxy, options, interceptors, serviceConfig))
.flatMap(
channel -> {
var serverCapabilitiesSingle =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Supplier;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -117,7 +116,6 @@ public GrpcCacheClient(
options.remoteInstanceName,
channel,
callCredentialsProvider,
options.remoteTimeout.toSeconds(),
retrier,
options.maximumOpenFiles,
digestUtil.getDigestFunction());
Expand Down Expand Up @@ -150,17 +148,15 @@ private ContentAddressableStorageFutureStub casFutureStub(
.withInterceptors(
TracingMetadataUtils.attachMetadataInterceptor(context.getRequestMetadata()),
new NetworkTimeInterceptor(context::getNetworkTime))
.withCallCredentials(callCredentialsProvider.getCallCredentials())
.withDeadlineAfter(options.remoteTimeout.toSeconds(), TimeUnit.SECONDS);
.withCallCredentials(callCredentialsProvider.getCallCredentials());
}

private ByteStreamStub bsAsyncStub(RemoteActionExecutionContext context, Channel channel) {
return ByteStreamGrpc.newStub(channel)
.withInterceptors(
TracingMetadataUtils.attachMetadataInterceptor(context.getRequestMetadata()),
new NetworkTimeInterceptor(context::getNetworkTime))
.withCallCredentials(callCredentialsProvider.getCallCredentials())
.withDeadlineAfter(options.remoteTimeout.toSeconds(), TimeUnit.SECONDS);
.withCallCredentials(callCredentialsProvider.getCallCredentials());
}

private ActionCacheFutureStub acFutureStub(
Expand All @@ -169,8 +165,7 @@ private ActionCacheFutureStub acFutureStub(
.withInterceptors(
TracingMetadataUtils.attachMetadataInterceptor(context.getRequestMetadata()),
new NetworkTimeInterceptor(context::getNetworkTime))
.withCallCredentials(callCredentialsProvider.getCallCredentials())
.withDeadlineAfter(options.remoteTimeout.toSeconds(), TimeUnit.SECONDS);
.withCallCredentials(callCredentialsProvider.getCallCredentials());
}

/**
Expand Down
Loading