Skip to content

Commit

Permalink
Wrap StatusRuntimeExceptions from GrpcRemoteCache
Browse files Browse the repository at this point in the history
Exceptions that occur during remote interactions are expected to be
wrapped in IOException for observation by the RemoteSpawn{Runner,Cache}
layers.

Fixes #7856

Closes #7860.

PiperOrigin-RevId: 240793745
  • Loading branch information
George Gensure authored and katre committed Mar 29, 2019
1 parent f092ec3 commit 42353c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public void onSuccess(byte[] b) {

@Override
public void onFailure(Throwable t) {
dirDownload.setException(t);
dirDownload.setException(new IOException(t));
}
},
MoreExecutors.directExecutor());
Expand Down Expand Up @@ -310,7 +310,16 @@ private static class FuturePathBooleanTuple {
private final boolean isExecutable;

public FuturePathBooleanTuple(ListenableFuture<?> future, Path path, boolean isExecutable) {
this.future = future;
this.future = Futures.catchingAsync(
future,
Throwable.class,
(t) -> {
if (t instanceof IOException) {
return Futures.immediateFailedFuture(t);
}
return Futures.immediateFailedFuture(new IOException(t));
},
MoreExecutors.directExecutor());
this.path = path;
this.isExecutable = isExecutable;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ public static boolean isRemoteCacheOptions(RemoteOptions options) {
private ListenableFuture<FindMissingBlobsResponse> getMissingDigests(
FindMissingBlobsRequest request) throws IOException, InterruptedException {
Context ctx = Context.current();
return retrier.executeAsync(() -> ctx.call(() -> casFutureStub().findMissingBlobs(request)));
try {
return retrier.executeAsync(() -> ctx.call(() -> casFutureStub().findMissingBlobs(request)));
} catch (StatusRuntimeException e) {
throw new IOException(e);
}
}

private ImmutableSet<Digest> getMissingDigests(Iterable<Digest> digests)
Expand Down

0 comments on commit 42353c6

Please sign in to comment.