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-Service 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
Expand Up @@ -20,6 +20,7 @@ Shreya Bhattarai <shreyax@google.com>
Kevin Bierhoff <kmb@google.com>
Klaas Boesche <klaasb@google.com>
Phil Bordelon <sunfall@google.com>
Mostyn Bramley-Moore <mostyn@antipode.se>
Jon Brandvein <brandjon@google.com>
Volker Braun <vbraun.name@gmail.com>
Thomas Broyer <t.broyer@ltgt.net>
Expand Down
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.