Skip to content

Commit

Permalink
Remote: handle early return of compressed blobs uploads (#14885)
Browse files Browse the repository at this point in the history
This is an implementation of this REAPI spec update:
bazelbuild/remote-apis#213

Here's a bazel-remote build that can be used to test this change:
buchgr/bazel-remote#527

Fixes #14654

Closes #14870.

PiperOrigin-RevId: 430167812
(cherry picked from commit d184e48)

Co-authored-by: Mostyn Bramley-Moore <[email protected]>
  • Loading branch information
brentleyjones and mostynb authored Feb 22, 2022
1 parent 031a772 commit 8ebd70b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Shreya Bhattarai <[email protected]>
Kevin Bierhoff <[email protected]>
Klaas Boesche <[email protected]>
Phil Bordelon <[email protected]>
Mostyn Bramley-Moore <[email protected]>
Jon Brandvein <[email protected]>
Volker Braun <[email protected]>
Thomas Broyer <[email protected]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,14 +440,33 @@ ListenableFuture<Void> start() {
// level/algorithm, so we cannot know the expected committed offset
long committedSize = committedOffset.get();
long expected = chunker.getOffset();
if (!chunker.hasNext() && committedSize != expected) {

if (committedSize == expected) {
// Both compressed and uncompressed uploads can succeed
// with this result.
return immediateVoidFuture();
}

if (chunker.isCompressed()) {
if (committedSize == -1) {
// Returned early, blob already available.
return immediateVoidFuture();
}

String message =
format(
"write incomplete: committed_size %d for %d total",
"compressed write incomplete: committed_size %d is neither -1 nor total %d",
committedSize, expected);
return Futures.immediateFailedFuture(new IOException(message));
}

// Uncompressed upload failed.
String message =
format(
"write incomplete: committed_size %d for %d total", committedSize, expected);
return Futures.immediateFailedFuture(new IOException(message));
}

return immediateVoidFuture();
},
MoreExecutors.directExecutor());
Expand Down

0 comments on commit 8ebd70b

Please sign in to comment.