Skip to content

Commit 0bd3d02

Browse files
committed
Clearer auth/re-auth related stream error log messages
At INFO level it wasn't possibly to distinguish these from other kinds of retryable stream errors.
1 parent 91adcc5 commit 0bd3d02

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

src/main/java/com/ibm/etcd/client/GrpcClient.java

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ public <ReqT,RespT> StreamObserver<ReqT> callStream(MethodDescriptor<ReqT,RespT>
336336
ResilientResponseObserver<ReqT,RespT> respStream, Executor responseExecutor) {
337337
// must explicitly auth in stream case to ensure unauthenticated version isn't used
338338
if (refreshCreds != null && getCallOptions() == CallOptions.DEFAULT) {
339+
// This will update callOptions with new CallCredentials prior to opening the stream
339340
authenticateNow();
340341
}
341342
return new ResilientBiDiStream<>(method, respStream, responseExecutor).start();
@@ -363,7 +364,7 @@ public static interface ResilientResponseObserver<ReqT,RespT> extends StreamObse
363364
}
364365

365366

366-
class ResilientBiDiStream<ReqT,RespT> {
367+
final class ResilientBiDiStream<ReqT,RespT> {
367368
private final MethodDescriptor<ReqT,RespT> method;
368369
private final ResilientResponseObserver<ReqT,RespT> respStream;
369370
private final Executor responseExecutor;
@@ -545,7 +546,7 @@ private void onFinish(Throwable err) {
545546
return;
546547
}
547548

548-
// don't treat this as final if authentication
549+
// Don't treat this as final if authentication
549550
// is enabled and the error reflects that reauth
550551
// is required - instead just cancel the "current"
551552
// stream which will cause the top-level stream
@@ -592,13 +593,25 @@ public void onError(Throwable t) {
592593
finalError = !reauthed && !retryableStreamError(t);
593594
}
594595
if (!finalError) {
595-
int errCount = ++errCounter;
596-
String msg = "Retryable onError #" + errCount
597-
+ " on underlying stream of method " + method.getFullMethodName();
598-
if (logger.isDebugEnabled()) {
599-
logger.info(msg, t);
596+
int errCount = -1;
597+
if (reauthed) {
598+
String msg = "Reauthenticating after auth error (likely expiry) on underlying"
599+
+ " stream of method " + method.getFullMethodName();
600+
if (logger.isDebugEnabled()) {
601+
logger.info(msg, t);
602+
} else {
603+
Throwable cause = Throwables.getRootCause(t);
604+
logger.info(msg + ": " + cause.getClass().getName() + ": " + cause.getMessage());
605+
}
600606
} else {
601-
logger.info(msg + ": " + t.getClass().getName() + ": " + t.getMessage());
607+
errCount = ++errCounter;
608+
String msg = "Retryable onError #" + errCount
609+
+ " on underlying stream of method " + method.getFullMethodName();
610+
if (logger.isDebugEnabled()) {
611+
logger.info(msg, t);
612+
} else {
613+
logger.info(msg + ": " + t.getClass().getName() + ": " + t.getMessage());
614+
}
602615
}
603616

604617
RequestSubStream userStreamBefore = userReqStream;

src/main/java/com/ibm/etcd/client/watch/EtcdWatchClient.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ public void onError(Throwable t) {
440440
onReplacedOrFailed(null, t instanceof Exception
441441
? (Exception) t : new RuntimeException(t));
442442
}
443+
443444
void onReplacedOrFailed(StreamObserver<WatchRequest> newRequestStream, Exception err) {
444445
List<WatcherRecord> pending = null;
445446
synchronized (EtcdWatchClient.this) {

0 commit comments

Comments
 (0)