Skip to content

Commit 8ebd70b

Browse files
Remote: handle early return of compressed blobs uploads (bazelbuild#14885)
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 <[email protected]>
1 parent 031a772 commit 8ebd70b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Shreya Bhattarai <[email protected]>
2020
Kevin Bierhoff <[email protected]>
2121
Klaas Boesche <[email protected]>
2222
Phil Bordelon <[email protected]>
23+
Mostyn Bramley-Moore <[email protected]>
2324
Jon Brandvein <[email protected]>
2425
Volker Braun <[email protected]>
2526
Thomas Broyer <[email protected]>

src/main/java/com/google/devtools/build/lib/remote/ByteStreamUploader.java

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,14 +440,33 @@ ListenableFuture<Void> start() {
440440
// level/algorithm, so we cannot know the expected committed offset
441441
long committedSize = committedOffset.get();
442442
long expected = chunker.getOffset();
443-
if (!chunker.hasNext() && committedSize != expected) {
443+
444+
if (committedSize == expected) {
445+
// Both compressed and uncompressed uploads can succeed
446+
// with this result.
447+
return immediateVoidFuture();
448+
}
449+
450+
if (chunker.isCompressed()) {
451+
if (committedSize == -1) {
452+
// Returned early, blob already available.
453+
return immediateVoidFuture();
454+
}
455+
444456
String message =
445457
format(
446-
"write incomplete: committed_size %d for %d total",
458+
"compressed write incomplete: committed_size %d is neither -1 nor total %d",
447459
committedSize, expected);
448460
return Futures.immediateFailedFuture(new IOException(message));
449461
}
462+
463+
// Uncompressed upload failed.
464+
String message =
465+
format(
466+
"write incomplete: committed_size %d for %d total", committedSize, expected);
467+
return Futures.immediateFailedFuture(new IOException(message));
450468
}
469+
451470
return immediateVoidFuture();
452471
},
453472
MoreExecutors.directExecutor());

0 commit comments

Comments
 (0)