From fded729515596789c21d4431396ebd0a10c0c1ad Mon Sep 17 00:00:00 2001 From: steinman Date: Mon, 3 Jun 2019 09:28:15 -0700 Subject: [PATCH] Cancel previous BEP upload if there is a connectivity problem. This should reduce the delay in waiting for the previous command to complete. RELNOTES: None. PiperOrigin-RevId: 251247368 --- .../BuildEventServiceModule.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java index 349a4e4f63fc81..8bcfb37b317d4a 100644 --- a/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java +++ b/src/main/java/com/google/devtools/build/lib/buildeventservice/BuildEventServiceModule.java @@ -190,6 +190,18 @@ private void waitForPreviousInvocation() { return; } + ConnectivityStatus status = connectivityProvider.getStatus(CONNECTIVITY_CACHE_KEY); + if (status.status != ConnectivityStatus.Status.OK) { + reporter.handle( + Event.info( + String.format( + "The Build Event Protocol encountered a connectivity problem: %s. Cancelling" + + " previous background uploads", + status))); + cancelPendingUploads(); + return; + } + Stopwatch stopwatch = Stopwatch.createStarted(); try { // TODO(b/234994611): It would be better to report before we wait, but the current @@ -616,8 +628,7 @@ private BuildEventServiceTransport createBesTransport( clearBesClient(); String message = String.format( - "Build Event Service uploads disabled due to a connectivity problem: %s", - status.toString()); + "Build Event Service uploads disabled due to a connectivity problem: %s", status); reporter.handle(Event.warn(message)); googleLogger.atWarning().log(message); return null;