Skip to content

Commit

Permalink
RemoteCache: replace getCacheCapabilities with getServerCapabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
sluongng committed Sep 16, 2024
1 parent b4af015 commit b7524f9
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import build.bazel.remote.execution.v2.ActionCacheGrpc;
import build.bazel.remote.execution.v2.ActionCacheGrpc.ActionCacheFutureStub;
import build.bazel.remote.execution.v2.ActionResult;
import build.bazel.remote.execution.v2.CacheCapabilities;
import build.bazel.remote.execution.v2.ContentAddressableStorageGrpc;
import build.bazel.remote.execution.v2.ContentAddressableStorageGrpc.ContentAddressableStorageFutureStub;
import build.bazel.remote.execution.v2.Digest;
Expand Down Expand Up @@ -260,11 +259,6 @@ private ListenableFuture<ActionResult> handleStatus(ListenableFuture<ActionResul
MoreExecutors.directExecutor());
}

@Override
public CacheCapabilities getCacheCapabilities() throws IOException {
return channel.getServerCapabilities().getCacheCapabilities();
}

@Override
public ServerCapabilities getServerCapabilities() throws IOException {
return channel.getServerCapabilities();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,7 @@ public RemoteCache(
}

public CacheCapabilities getRemoteCacheCapabilities() throws IOException {
if (remoteCacheClient == null) {
return CacheCapabilities.getDefaultInstance();
}
return remoteCacheClient.getCacheCapabilities();
return getServerCapabilities().getCacheCapabilities();
}

public ListenableFuture<String> getRemoteAuthority() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import build.bazel.remote.execution.v2.Action;
import build.bazel.remote.execution.v2.ActionResult;
import build.bazel.remote.execution.v2.CacheCapabilities;
import build.bazel.remote.execution.v2.Digest;
import build.bazel.remote.execution.v2.ServerCapabilities;
import com.google.common.base.Preconditions;
Expand All @@ -33,8 +32,6 @@
* <p>Implementations must be thread-safe.
*/
public interface RemoteCacheClient extends MissingDigestsFinder {
CacheCapabilities getCacheCapabilities() throws IOException;

ServerCapabilities getServerCapabilities() throws IOException;

ListenableFuture<String> getAuthority();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,18 +603,15 @@ private void getAfterCredentialRefresh(DownloadCommand cmd, SettableFuture<Void>
});
}

@Override
public CacheCapabilities getCacheCapabilities() {
return CacheCapabilities.newBuilder()
.setActionCacheUpdateCapabilities(
ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build())
.setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED)
.build();
}

@Override
public ServerCapabilities getServerCapabilities() {
return ServerCapabilities.newBuilder().setCacheCapabilities(getCacheCapabilities()).build();
var cacheCapabilities =
CacheCapabilities.newBuilder()
.setActionCacheUpdateCapabilities(
ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build())
.setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED)
.build();
return ServerCapabilities.newBuilder().setCacheCapabilities(cacheCapabilities).build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import build.bazel.remote.execution.v2.ActionCacheUpdateCapabilities;
import build.bazel.remote.execution.v2.ActionResult;
import build.bazel.remote.execution.v2.CacheCapabilities;
import build.bazel.remote.execution.v2.Digest;
import build.bazel.remote.execution.v2.Directory;
import build.bazel.remote.execution.v2.DirectoryNode;
Expand All @@ -48,6 +50,7 @@
import build.bazel.remote.execution.v2.Platform;
import build.bazel.remote.execution.v2.RequestMetadata;
import build.bazel.remote.execution.v2.ServerCapabilities;
import build.bazel.remote.execution.v2.SymlinkAbsolutePathStrategy;
import build.bazel.remote.execution.v2.SymlinkNode;
import build.bazel.remote.execution.v2.Tree;
import com.google.common.base.Throwables;
Expand Down Expand Up @@ -155,17 +158,25 @@ public class RemoteExecutionServiceTest {
private final Reporter reporter = new Reporter(new EventBus());
private final StoredEventHandler eventHandler = new StoredEventHandler();

private final CacheCapabilities cacheCapabilities =
CacheCapabilities.newBuilder()
.setActionCacheUpdateCapabilities(
ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build())
.setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED)
.build();
// In the past, Bazel only supports RemoteApi version 2.0.
// Use this to ensure we are backward compatible with Servers that only support 2.0.
private final ServerCapabilities legacyRemoteExecutorCapabilities =
ServerCapabilities.newBuilder()
.setCacheCapabilities(cacheCapabilities)
.setLowApiVersion(ApiVersion.twoPointZero.toSemVer())
.setHighApiVersion(ApiVersion.twoPointZero.toSemVer())
.setExecutionCapabilities(ExecutionCapabilities.newBuilder().setExecEnabled(true).build())
.build();

private final ServerCapabilities remoteExecutorCapabilities =
ServerCapabilities.newBuilder()
.setCacheCapabilities(cacheCapabilities)
.setLowApiVersion(ApiVersion.low.toSemVer())
.setHighApiVersion(ApiVersion.high.toSemVer())
.setExecutionCapabilities(ExecutionCapabilities.newBuilder().setExecEnabled(true).build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,15 @@ public ListenableFuture<Void> downloadBlob(
return Futures.immediateFuture(null);
}

@Override
public CacheCapabilities getCacheCapabilities() {
return CacheCapabilities.newBuilder()
.setActionCacheUpdateCapabilities(
ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build())
.setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED)
.build();
}

@Override
public ServerCapabilities getServerCapabilities() {
return ServerCapabilities.getDefaultInstance();
var cacheCapabilities =
CacheCapabilities.newBuilder()
.setActionCacheUpdateCapabilities(
ActionCacheUpdateCapabilities.newBuilder().setUpdateEnabled(true).build())
.setSymlinkAbsolutePathStrategy(SymlinkAbsolutePathStrategy.Value.ALLOWED)
.build();
return ServerCapabilities.newBuilder().setCacheCapabilities(cacheCapabilities).build();
}

@Override
Expand Down

0 comments on commit b7524f9

Please sign in to comment.