From c56c489119e6587975964c44ceb9e429ad950736 Mon Sep 17 00:00:00 2001 From: George Gensure Date: Thu, 28 Mar 2019 09:58:35 -0700 Subject: [PATCH] Wrap StatusRuntimeExceptions from GrpcRemoteCache 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 --- .../build/lib/remote/AbstractRemoteActionCache.java | 13 +++++++++++-- .../devtools/build/lib/remote/GrpcRemoteCache.java | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java b/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java index e052071ce829f8..523a414570d666 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/AbstractRemoteActionCache.java @@ -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()); @@ -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; } diff --git a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java index 7d459b5789772d..3b185ff5fc77de 100644 --- a/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java +++ b/src/main/java/com/google/devtools/build/lib/remote/GrpcRemoteCache.java @@ -151,7 +151,11 @@ public static boolean isRemoteCacheOptions(RemoteOptions options) { private ListenableFuture 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 getMissingDigests(Iterable digests)