Skip to content

Commit

Permalink
Properly wire up BES half-close. The lack thereof was a simple oversi…
Browse files Browse the repository at this point in the history
…ght.

With this change, --bes_upload_mode=fully_async works properly.

RELNOTES: None
PiperOrigin-RevId: 251295660
  • Loading branch information
ericfelly authored and Copybara-Service committed Jun 3, 2019
1 parent ce5e718 commit 3ed9d36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public ListenableFuture<Void> close() {
return besUploader.close();
}

@Override
public ListenableFuture<Void> getHalfCloseFuture() {
return besUploader.getHalfCloseFuture();
}

@Override
public BuildEventArtifactUploader getUploader() {
return besUploader.getLocalFileUploader();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ private BuildEventServiceUploader(
this.clock = clock;
this.namer = namer;
this.eventBus = eventBus;
// Ensure the half-close future is closed once the upload is complete. This is usually a no-op,
// but makes sure we half-close in case of error / interrupt.
closeFuture.addListener(
() -> halfCloseFuture.setFuture(closeFuture), MoreExecutors.directExecutor());
}

BuildEventArtifactUploader getLocalFileUploader() {
Expand Down Expand Up @@ -255,6 +259,10 @@ private void closeNow() {
}
}

ListenableFuture<Void> getHalfCloseFuture() {
return halfCloseFuture;
}

private void logAndExitAbruptly(String message, ExitCode exitCode, Throwable cause) {
checkState(!exitCode.equals(ExitCode.SUCCESS));
logger.severe(message);
Expand Down Expand Up @@ -422,6 +430,7 @@ private void publishBuildEvents()
streamContext.sendOverStream(request);
streamContext.halfCloseStream();
halfCloseFuture.set(null);
logger.info("BES uploader is half-closed");
}
break;

Expand Down

0 comments on commit 3ed9d36

Please sign in to comment.