-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Status error presentation with details
Remote Execution Status messages embedded in ExecuteResponses are extremely capable vehicles for conveying the nature of an error, and informing a user of further steps to take to remediate it. This change expands the presentation of these response Statuses, and brings all of the error details to light, by default instead of requiring --verbose_failures to investigate any details of a remote execution problem. The interpretation of precondition failures to highlight retriable responses has been expanded to ignore benign details that might be included in a response. SpawnResult error message composition has been simplified substantially, without any special behavior for 'Remote' errors, and a removal of a duplicate message printout incurred in the wake of succcessive @janakr and @olaola changes. Failure messages are now implied to be present in all spawn result failure reporting exactly once, and the failureMessage of a SpawnResult is implied to be the parameter to getDetailMessage. An example error presentation is as follows (including the modifications to SpawnResult's output formatting): ``` ERROR: /home/werkt/dev/test/BUILD:22:10: Linking test failed: (Exit 34): Remote Execution Failure: Failed Precondition: Action 4223ab2cc114385110714243a0b4a88cc743f2169b5be7d4d438a6bbba4f529f/142 is invalid Resource Info: type.googleapis.com/google.longrunning.Operation: name='shard/operations/9335fef2-184b-4d26-9a6f-2f27cebe7527', owner='tool_invocation_id:4b4bf7b1-fadd-44fd-99be-a234e7c26fc4,correlated_invocation_id:dc88325a-9317-48c0-9013-b3bb8b7a458f' Precondition Failure: (MISSING) bazel-out/k8-fastbuild/bin/test: 7872: An output could not be uploaded because it exceeded the maximum size of an entry Target //:test failed to build ``` Closes #12564. PiperOrigin-RevId: 3449738
- Loading branch information
1 parent
12b655b
commit 5122617
Showing
13 changed files
with
382 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
src/main/java/com/google/devtools/build/lib/remote/ExecuteRetrier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// Copyright 2020 The Bazel Authors. All rights reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package com.google.devtools.build.lib.remote; | ||
|
||
import com.google.common.util.concurrent.ListeningScheduledExecutorService; | ||
import com.google.protobuf.Any; | ||
import com.google.protobuf.InvalidProtocolBufferException; | ||
import com.google.protobuf.util.Durations; | ||
import com.google.rpc.DebugInfo; | ||
import com.google.rpc.Help; | ||
import com.google.rpc.LocalizedMessage; | ||
import com.google.rpc.PreconditionFailure; | ||
import com.google.rpc.PreconditionFailure.Violation; | ||
import com.google.rpc.RequestInfo; | ||
import com.google.rpc.ResourceInfo; | ||
import com.google.rpc.RetryInfo; | ||
import com.google.rpc.Status; | ||
import io.grpc.Status.Code; | ||
import io.grpc.protobuf.StatusProto; | ||
|
||
/** Specific retry logic for execute request with gapi Status. */ | ||
class ExecuteRetrier extends RemoteRetrier { | ||
|
||
private static final String VIOLATION_TYPE_MISSING = "MISSING"; | ||
|
||
private static class RetryInfoBackoff implements Backoff { | ||
private final int maxRetryAttempts; | ||
int retries = 0; | ||
|
||
RetryInfoBackoff(int maxRetryAttempts) { | ||
this.maxRetryAttempts = maxRetryAttempts; | ||
} | ||
|
||
@Override | ||
public long nextDelayMillis(Exception e) { | ||
if (retries >= maxRetryAttempts) { | ||
return -1; | ||
} | ||
RetryInfo retryInfo = getRetryInfo(e); | ||
retries++; | ||
return Durations.toMillis(retryInfo.getRetryDelay()); | ||
} | ||
|
||
RetryInfo getRetryInfo(Exception e) { | ||
RetryInfo retryInfo = RetryInfo.getDefaultInstance(); | ||
Status status = StatusProto.fromThrowable(e); | ||
if (status != null) { | ||
for (Any detail : status.getDetailsList()) { | ||
if (detail.is(RetryInfo.class)) { | ||
try { | ||
retryInfo = detail.unpack(RetryInfo.class); | ||
} catch (InvalidProtocolBufferException protoEx) { | ||
// really shouldn't happen, ignore | ||
} | ||
} | ||
} | ||
} | ||
return retryInfo; | ||
} | ||
|
||
@Override | ||
public int getRetryAttempts() { | ||
return retries; | ||
} | ||
} | ||
|
||
ExecuteRetrier( | ||
int maxRetryAttempts, | ||
ListeningScheduledExecutorService retryService, | ||
CircuitBreaker circuitBreaker) { | ||
super( | ||
() -> maxRetryAttempts > 0 ? new RetryInfoBackoff(maxRetryAttempts) : RETRIES_DISABLED, | ||
ExecuteRetrier::shouldRetry, | ||
retryService, | ||
circuitBreaker); | ||
} | ||
|
||
private static boolean shouldRetry(Exception e) { | ||
if (BulkTransferException.isOnlyCausedByCacheNotFoundException(e)) { | ||
return true; | ||
} | ||
Status status = StatusProto.fromThrowable(e); | ||
if (status == null || status.getDetailsCount() == 0) { | ||
return false; | ||
} | ||
boolean failedPrecondition = status.getCode() == Code.FAILED_PRECONDITION.value(); | ||
for (Any detail : status.getDetailsList()) { | ||
if (detail.is(RetryInfo.class)) { | ||
// server says we can retry, regardless of other details | ||
return true; | ||
} else if (failedPrecondition) { | ||
if (detail.is(PreconditionFailure.class)) { | ||
try { | ||
PreconditionFailure f = detail.unpack(PreconditionFailure.class); | ||
if (f.getViolationsCount() == 0) { | ||
failedPrecondition = false; | ||
} | ||
for (Violation v : f.getViolationsList()) { | ||
if (!v.getType().equals(VIOLATION_TYPE_MISSING)) { | ||
failedPrecondition = false; | ||
} | ||
} | ||
// if *all* > 0 precondition failure violations have type MISSING, failedPrecondition | ||
// remains true | ||
} catch (InvalidProtocolBufferException protoEx) { | ||
// really shouldn't happen | ||
return false; | ||
} | ||
} else if (!(detail.is(DebugInfo.class) | ||
|| detail.is(Help.class) | ||
|| detail.is(LocalizedMessage.class) | ||
|| detail.is(RequestInfo.class) | ||
|| detail.is(ResourceInfo.class))) { // ignore benign details | ||
// consider all other details as failures | ||
failedPrecondition = false; | ||
} | ||
} | ||
} | ||
return failedPrecondition; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.