Don't log with warn level in the DnsNameResolver in most cases (#10225)

Motivation:

We should only log with warn level if something really critical happens as otherwise we may spam logs and confuse the user.

Modifications:

- Change log level to debug for most cases

Result:

Less noisy logging
This commit is contained in:
Norman Maurer 2020-04-29 08:00:14 +02:00
parent fe20550a22
commit 7b56aabec6

View File

@ -34,6 +34,7 @@ import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.DatagramPacket;
import io.netty.channel.socket.InternetProtocolFamily;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.CorruptedFrameException;
import io.netty.handler.codec.dns.DatagramDnsQueryEncoder;
import io.netty.handler.codec.dns.DatagramDnsResponse;
import io.netty.handler.codec.dns.DatagramDnsResponseDecoder;
@ -1205,7 +1206,7 @@ public class DnsNameResolver extends InetNameResolver {
final DnsQueryContext qCtx = queryContextManager.get(res.sender(), queryId);
if (qCtx == null) {
logger.warn("{} Received a DNS response with an unknown ID: {}", ch, queryId);
logger.debug("Received a DNS response with an unknown ID: UDP [{}: {}]", ch, queryId);
res.release();
return;
}
@ -1260,9 +1261,9 @@ public class DnsNameResolver extends InetNameResolver {
response));
} else {
response.release();
tcpCtx.tryFailure("Received TCP response with unexpected ID", null, false);
logger.warn("{} Received a DNS response with an unexpected ID: {}",
channel, queryId1);
tcpCtx.tryFailure("Received TCP DNS response with unexpected ID", null, false);
logger.debug("Received a DNS response with an unexpected ID: TCP [{}: {}]",
channel, queryId);
}
}
@ -1304,7 +1305,11 @@ public class DnsNameResolver extends InetNameResolver {
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
logger.warn("{} Unexpected exception: ", ctx.channel(), cause);
if (cause instanceof CorruptedFrameException) {
logger.debug("Unable to decode DNS response: UDP [{}]", ctx.channel(), cause);
} else {
logger.warn("Unexpected exception: UDP [{}]", ctx.channel(), cause);
}
}
}