You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by ez...@apache.org on 2022/09/05 16:29:13 UTC

[trafficserver] branch master updated: dns error logging to diags (#9018)

This is an automated email from the ASF dual-hosted git repository.

eze pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 79adaf378 dns error logging to diags (#9018)
79adaf378 is described below

commit 79adaf378f6fd98094d4e8d2065657170d734645
Author: Fabi Dias <11...@users.noreply.github.com>
AuthorDate: Mon Sep 5 10:29:08 2022 -0600

    dns error logging to diags (#9018)
    
    * dns error logging to diags
    
    Co-authored-by: Fabielle Dias <>
---
 iocore/dns/DNS.cc | 41 ++++++++++++++++++++++++++++++++---------
 1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc
index c8da7474d..c22ce9b2a 100644
--- a/iocore/dns/DNS.cc
+++ b/iocore/dns/DNS.cc
@@ -1529,6 +1529,24 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len)
   bool server_ok    = true;
   uint32_t temp_ttl = 0;
 
+  const char *RCODE_NAME[] = {
+    "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED", "YXDOMAIN", "YXRRSET", "NXRRSET", "NOTAUTH", "NOTZONE",
+  };
+
+  const char *RCODE_DESCRIPTION[] = {
+    "No Error",
+    "Format Error",
+    "Server Failure",
+    "Non-Existent Domain",
+    "Not Implemented",
+    "Query Refused",
+    "Name Exists when it should not",
+    "RR Set Exists when it should not",
+    "RR Set that should exist does not",
+    "Not Authorized",
+    "Name not contained in zone",
+  };
+
   //
   // Do we have an entry for this id?
   //
@@ -1553,31 +1571,36 @@ dns_process(DNSHandler *handler, HostEnt *buf, int len)
     goto Lerror;
   }
 
+  // Logs using SiteThrottled* version is helpful for noisy logs, being used here
+  // instead of print statements to help with the possible retries when a dns code occurs
   if (h->rcode != NOERROR || !h->ancount) {
     Debug("dns", "received rcode = %d", h->rcode);
     switch (h->rcode) {
     default:
-      Warning("Unknown DNS error %d for [%s]", h->rcode, e->qname);
+      SiteThrottledWarning("UNKNOWN: DNS error %d for [%s]", h->rcode, e->qname);
       retry     = true;
       server_ok = false; // could be server problems
       goto Lerror;
+    case NOERROR: // included for completeness.
+      Debug("dns", "%s: DNS error %d for [%s]: %s", RCODE_NAME[h->rcode], h->rcode, e->qname, RCODE_DESCRIPTION[h->rcode]);
+      break;
     case SERVFAIL: // recoverable error
+      SiteThrottledNote("%s: DNS error %d for [%s]: %s", RCODE_NAME[h->rcode], h->rcode, e->qname, RCODE_DESCRIPTION[h->rcode]);
       retry = true;
       break;
     case FORMERR: // unrecoverable errors
     case REFUSED:
     case NOTIMP:
-      Debug("dns", "DNS error %d for [%s]", h->rcode, e->qname);
+      SiteThrottledNote("%s: DNS error %d for [%s]: %s", RCODE_NAME[h->rcode], h->rcode, e->qname, RCODE_DESCRIPTION[h->rcode]);
       server_ok = false; // could be server problems
       goto Lerror;
-    case NOERROR:
     case NXDOMAIN:
-    case 6:  // YXDOMAIN
-    case 7:  // YXRRSET
-    case 8:  // NOTAUTH
-    case 9:  // NOTAUTH
-    case 10: // NOTZONE
-      Debug("dns", "DNS error %d for [%s]", h->rcode, e->qname);
+    case YXDOMAIN:
+    case YXRRSET:
+    case NXRRSET:
+    case NOTAUTH:
+    case NOTZONE:
+      SiteThrottledNote("%s: DNS error %d for [%s]: %s", RCODE_NAME[h->rcode], h->rcode, e->qname, RCODE_DESCRIPTION[h->rcode]);
       goto Lerror;
     }
   } else {