mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 23:03:34 +02:00
Log non-200 response at warning
The previous CL had a bug as non-200 response are outbound errors and are not caught in exceptionCaught() method. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208063877
This commit is contained in:
parent
58e68db386
commit
f554ace51b
1 changed files with 14 additions and 9 deletions
|
@ -17,6 +17,7 @@ package google.registry.proxy.handler;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.flogger.FluentLogger;
|
import com.google.common.flogger.FluentLogger;
|
||||||
import google.registry.proxy.metric.FrontendMetrics;
|
import google.registry.proxy.metric.FrontendMetrics;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
|
@ -154,7 +155,7 @@ abstract class HttpsRelayServiceHandler extends ByteToMessageCodec<FullHttpRespo
|
||||||
throws Exception {
|
throws Exception {
|
||||||
checkArgument(
|
checkArgument(
|
||||||
response.status().equals(HttpResponseStatus.OK),
|
response.status().equals(HttpResponseStatus.OK),
|
||||||
"Cannot relay HTTP response status \"%s\"in channel %s:\n%s",
|
"Cannot relay HTTP response status \"%s\" in channel %s:\n%s",
|
||||||
response.status(),
|
response.status(),
|
||||||
ctx.channel(),
|
ctx.channel(),
|
||||||
response.content().toString(UTF_8));
|
response.content().toString(UTF_8));
|
||||||
|
@ -166,14 +167,9 @@ abstract class HttpsRelayServiceHandler extends ByteToMessageCodec<FullHttpRespo
|
||||||
@Override
|
@Override
|
||||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||||
// ReadTimeoutException is non fatal as the client times out due to inactivity.
|
// ReadTimeoutException is non fatal as the client times out due to inactivity.
|
||||||
// IllegalArgumentException is thrown by the checkArgument in the #encode command, it just means
|
|
||||||
// that GAE returns a non-200 response and the connection should be killed. The request is still
|
|
||||||
// processed by GAE, so this is not an unexpected behavior.
|
|
||||||
// SslHandshakeException is caused by the client not able to complete the handshake, we should
|
// SslHandshakeException is caused by the client not able to complete the handshake, we should
|
||||||
// not log it at error as we do not control client behavior.
|
// not log it at error as we do not control client behavior.
|
||||||
if (cause instanceof ReadTimeoutException
|
if (cause instanceof ReadTimeoutException || cause instanceof SSLHandshakeException) {
|
||||||
|| cause instanceof IllegalArgumentException
|
|
||||||
|| cause instanceof SSLHandshakeException) {
|
|
||||||
logger.atWarning().withCause(cause).log(
|
logger.atWarning().withCause(cause).log(
|
||||||
"Inbound exception caught for channel %s", ctx.channel());
|
"Inbound exception caught for channel %s", ctx.channel());
|
||||||
} else {
|
} else {
|
||||||
|
@ -190,8 +186,17 @@ abstract class HttpsRelayServiceHandler extends ByteToMessageCodec<FullHttpRespo
|
||||||
promise.addListener(
|
promise.addListener(
|
||||||
(ChannelFuture channelFuture) -> {
|
(ChannelFuture channelFuture) -> {
|
||||||
if (!channelFuture.isSuccess()) {
|
if (!channelFuture.isSuccess()) {
|
||||||
logger.atSevere().withCause(channelFuture.cause()).log(
|
Throwable cause = channelFuture.cause();
|
||||||
"Outbound exception caught for channel %s", channelFuture.channel());
|
// If the failure is caused by IllegalArgumentException, we know that it is because we
|
||||||
|
// got a non 200 response. This is an expected error from the backend and should not be
|
||||||
|
// logged at severe.
|
||||||
|
if (Throwables.getRootCause(cause) instanceof IllegalArgumentException) {
|
||||||
|
logger.atWarning().withCause(channelFuture.cause()).log(
|
||||||
|
"Outbound exception caught for channel %s", channelFuture.channel());
|
||||||
|
} else {
|
||||||
|
logger.atSevere().withCause(channelFuture.cause()).log(
|
||||||
|
"Outbound exception caught for channel %s", channelFuture.channel());
|
||||||
|
}
|
||||||
ChannelFuture unusedFuture = channelFuture.channel().close();
|
ChannelFuture unusedFuture = channelFuture.channel().close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue