diff --git a/kong/resty/dns_client/init.lua b/kong/resty/dns_client/init.lua index ad66c53afc9c..793a266e0f9a 100644 --- a/kong/resty/dns_client/init.lua +++ b/kong/resty/dns_client/init.lua @@ -306,7 +306,6 @@ local function resolve_all(self, name, opts, tries) -- lookup fastly: no callback, which is only used for real network query local answers, err, hit_level = self.cache:get(name) - if not answers then answers, err, tries = resolve_names_and_types(self, name, opts, tries) if answers then @@ -343,8 +342,8 @@ function _M:resolve(name, opts, tries) -- option: return_random if answers[1].type == resolver.TYPE_SRV then - local answer = utils.get_rrw_ans(answers) - opts.port = (answer.port ~= 0 and answer.port) or opts.port + local answer = utils.get_wrr_ans(answers) + opts.port = answer.port ~= 0 and answer.port or opts.port return self:resolve(answer.target, opts, tries) end diff --git a/kong/resty/dns_client/utils.lua b/kong/resty/dns_client/utils.lua index 8c548c7b1020..a9347ade39c0 100644 --- a/kong/resty/dns_client/utils.lua +++ b/kong/resty/dns_client/utils.lua @@ -40,7 +40,7 @@ function _M.is_fqdn(name, ndots) end --- construct from resolv options: search/ndots and domain +-- construct names from resolv options: search, ndots and domain function _M.search_names(name, resolv) if not resolv.search or _M.is_fqdn(name, resolv.ndots) then return { name }