bes: don't retry all status codes
don't retry precondition_failed and
invalid_argument status codes.
RELNOTES: None
@@ -26,6 +26,7 @@ import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
@@ -57,6 +58,7 @@ import com.google.devtools.build.v1.PublishBuildToolEventStreamResponse;
import com.google.devtools.build.v1.PublishLifecycleEventRequest;
import com.google.protobuf.Any;
import io.grpc.Status;
+import io.grpc.Status.Code;
import io.grpc.StatusException;
import java.time.Duration;
import java.util.Collection;
@@ -85,6 +87,9 @@ public class BuildEventServiceTransport implements BuildEventTransport {
static final String UPLOAD_SUCCEEDED_MESSAGE =
"Build Event Protocol upload finished successfully.";
+ static final Set<Code> CODES_NOT_TO_RETRY =
+ Sets.newHashSet(Code.INVALID_ARGUMENT, Code.FAILED_PRECONDITION);
+
private static final Logger logger = Logger.getLogger(BuildEventServiceTransport.class.getName());
/** Max wait time until for the Streaming RPC to finish after all events were sent. */
@@ -597,11 +602,13 @@ public class BuildEventServiceTransport implements BuildEventTransport {
c.call();
lastRetryError = null;
return;
- } catch (InterruptedException e) {
- throw e;
} catch (LocalFileUploadException e) {
throw (Exception) e.getCause();
} catch (StatusException e) {
+ if (CODES_NOT_TO_RETRY.contains(e.getStatus().getCode())) {
+ throw e;
+ }
+
if (acksReceivedSinceLastRetry.get() > 0) {
logger.fine(
String.format(
