Skip to content

Commit

Permalink
Fix hanging issue when Bazel failed to upload action inputs
Browse files Browse the repository at this point in the history
Fixes #16422.

Closes #16423.
Closes #16445.

Closes #16464.

PiperOrigin-RevId: 480896881
Change-Id: I33019dbe8a088410280759465100a512a0f61bc1
  • Loading branch information
coeuvre authored and Copybara-Service committed Oct 13, 2022
1 parent b682d63 commit 8b61746
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ public void onComplete() {

@Override
public void onError(@NonNull Throwable e) {
Disposable d = uploadTask.disposable.get();
if (d != null && d.isDisposed()) {
return;
}

completion.onError(e);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.Maps;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
Expand Down Expand Up @@ -79,6 +80,7 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -565,6 +567,29 @@ public void ensureInputsPresent_interruptedDuringUploadBlobs_cancelInProgressUpl
assertThat(remoteCache.casUploadCache.getFinishedTasks()).hasSize(3);
}

@Test
public void ensureInputsPresent_uploadFailed_propagateErrors() throws Exception {
RemoteCacheClient cacheProtocol = spy(new InMemoryCacheClient());
doAnswer(invocationOnMock -> Futures.immediateFailedFuture(new IOException("upload failed")))
.when(cacheProtocol)
.uploadBlob(any(), any(), any());
doAnswer(invocationOnMock -> Futures.immediateFailedFuture(new IOException("upload failed")))
.when(cacheProtocol)
.uploadFile(any(), any(), any());
RemoteExecutionCache remoteCache = spy(newRemoteExecutionCache(cacheProtocol));
Path path = fs.getPath("/execroot/foo");
FileSystemUtils.writeContentAsLatin1(path, "bar");
SortedMap<PathFragment, Path> inputs = ImmutableSortedMap.of(PathFragment.create("foo"), path);
MerkleTree merkleTree = MerkleTree.build(inputs, digestUtil);

IOException e =
Assert.assertThrows(
IOException.class,
() -> remoteCache.ensureInputsPresent(context, merkleTree, ImmutableMap.of(), false));

assertThat(e).hasMessageThat().contains("upload failed");
}

@Test
public void shutdownNow_cancelInProgressUploads() throws Exception {
RemoteCacheClient remoteCacheClient = mock(RemoteCacheClient.class);
Expand Down

0 comments on commit 8b61746

Please sign in to comment.