Skip to content

Commit

Permalink
Remote: handle early return of compressed blobs uploads (bazelbuild#1…
Browse files Browse the repository at this point in the history
…4885)

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
(cherry picked from commit d184e48)

Co-authored-by: Mostyn Bramley-Moore <mostyn@antipode.se>
  • 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 <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
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.