Skip to content

Commit

Permalink
Remote: handle early return of compressed blobs uploads
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 bazelbuild#14654

Closes bazelbuild#14870.

PiperOrigin-RevId: 430167812
  • Loading branch information
mostynb authored and copybara-github committed Feb 22, 2022
1 parent 3fd0ffa commit d184e48
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 @@ -323,14 +323,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 d184e48

Please sign in to comment.