From b698699fdd90a1b9196c259fab069bdae80a5a27 Mon Sep 17 00:00:00 2001 From: Thomas Jackson Date: Sat, 12 Oct 2019 16:42:27 -0700 Subject: [PATCH] More helpful DNS failure message Previously if dns.lua failed to resolve a name you'd see the following in your logs: ``` 2019/10/12 23:39:34 [error] 41#41: *6474 [lua] dns.lua:121: dns_lookup(): failed to query the DNS server: server returned error code: 3: name error server returned error code: 3: name error, context: ngx.timer ``` Unfortunately this doesn't tell you what name is failing (so you have to start guessing). To alleviate the pain this simply adds the host name we are attempting to resolve to the log line so users don't have to guess. --- rootfs/etc/nginx/lua/util/dns.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rootfs/etc/nginx/lua/util/dns.lua b/rootfs/etc/nginx/lua/util/dns.lua index fcef83767..8ba5f3db1 100644 --- a/rootfs/etc/nginx/lua/util/dns.lua +++ b/rootfs/etc/nginx/lua/util/dns.lua @@ -118,7 +118,7 @@ function _M.lookup(host) return addresses end - ngx_log(ngx_ERR, "failed to query the DNS server:\n" .. table_concat(dns_errors, "\n")) + ngx_log(ngx_ERR, "failed to query the DNS server for %s:\n%s", host, table_concat(dns_errors, "\n")) return { host } end @@ -147,7 +147,7 @@ function _M.lookup(host) end if #dns_errors > 0 then - ngx_log(ngx_ERR, "failed to query the DNS server:\n" .. table_concat(dns_errors, "\n")) + ngx_log(ngx_ERR, "failed to query the DNS server for %s:\n%s", host, table_concat(dns_errors, "\n")) end return { host }