Skip to content

Commit 4cdb6da

Browse files
fix: retry INTERNAL retriable auth errors (#2239)
* fix: retry INTERNAL retriable auth errors Change-Id: I3939a89d40ecd4304bccaf0340fe169d6a083712 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent d1bceb0 commit 4cdb6da

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/ConvertExceptionCallable.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,20 @@ protected void onCompleteImpl() {
7777
private Throwable convertException(Throwable t) {
7878
// Long lived connections sometimes are disconnected via an RST frame or a goaway. These errors
7979
// are transient and should be retried.
80-
if (isRstStreamError(t) || isGoAway(t)) {
80+
if (isRstStreamError(t) || isGoAway(t) || isRetriableAuthError(t)) {
8181
return new InternalException(t, ((InternalException) t).getStatusCode(), true);
8282
}
8383
return t;
8484
}
8585

86+
private boolean isRetriableAuthError(Throwable t) {
87+
if (t instanceof InternalException && t.getMessage() != null) {
88+
String error = t.getMessage();
89+
return error.contains("Authentication backend internal server error. Please retry");
90+
}
91+
return false;
92+
}
93+
8694
private boolean isRstStreamError(Throwable t) {
8795
if (t instanceof InternalException && t.getMessage() != null) {
8896
String error = t.getMessage().toLowerCase();

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/ConvertExceptionCallableTest.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,32 @@ public void rstStreamExceptionConvertedToRetryableTest() {
5959
assertTrue(actualException.isRetryable());
6060
}
6161

62+
@Test
63+
public void retriableAuthExceptionConvertedToRetryableTest() {
64+
ApiException originalException =
65+
new InternalException(
66+
new StatusRuntimeException(
67+
Status.INTERNAL.withDescription(
68+
"Authentication backend internal server error. Please retry")),
69+
GrpcStatusCode.of(Status.Code.INTERNAL),
70+
false);
71+
assertFalse(originalException.isRetryable());
72+
SettableExceptionCallable<String, String> settableExceptionCallable =
73+
new SettableExceptionCallable<>(originalException);
74+
ConvertExceptionCallable<String, String> convertStreamExceptionCallable =
75+
new ConvertExceptionCallable<>(settableExceptionCallable);
76+
77+
Throwable actualError = null;
78+
try {
79+
convertStreamExceptionCallable.all().call("fake-request");
80+
} catch (Throwable t) {
81+
actualError = t;
82+
}
83+
assert actualError instanceof InternalException;
84+
InternalException actualException = (InternalException) actualError;
85+
assertTrue(actualException.isRetryable());
86+
}
87+
6288
private static final class SettableExceptionCallable<RequestT, ResponseT>
6389
extends ServerStreamingCallable<RequestT, ResponseT> {
6490
private final Throwable throwable;

0 commit comments

Comments
 (0)