Skip to content
This repository has been archived by the owner on Jul 11, 2023. It is now read-only.

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
Co-Authored-By: Enrique García Cota <[email protected]>
  • Loading branch information
Tieske and kikito committed Aug 7, 2019
1 parent fb1e92a commit dd92320
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Versioning is strictly based on [Semantic Versioning](https://semver.org/)

### 4.1.0 (unreleased)

- Fix: unhelthy balancers would not recover because they would not refresh the
- Fix: unhealthy balancers would not recover because they would not refresh the
DNS records used. See [PR 73](https://github.com/Kong/lua-resty-dns-client/pull/73).
- Added: automatic background resolving of hostnames, expiry will be checked
every second, and if needed DNS (and balancer) will be updated. See [PR 73](https://github.com/Kong/lua-resty-dns-client/pull/73).
Expand Down
7 changes: 2 additions & 5 deletions src/resty/dns/balancer/base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ local table_concat = table.concat
local math_floor = math.floor
local string_format = string.format
local ngx_log = ngx.log
local ngx_ERR = ngx.ERR
local ngx_DEBUG = ngx.DEBUG
local ngx_WARN = ngx.WARN
local balancer_id_counter = 0
Expand Down Expand Up @@ -1197,16 +1196,14 @@ end
-- Timer invoked to update DNS records
function objBalancer:resolveTimerCallback()
--check all hosts for expired records,
--erroreed ones included
--including those with errors
--we update, so changes on the list while traversing can happen, keep track of that

ngx_log(ngx_DEBUG, self.log_prefix, "executing requery timer")

local all_ok = true
for _, host in ipairs(self.hosts) do
-- only retry the errorred ones
if (host.lastQuery.expire or 0) < time() then
all_ok = false -- note: only if NO requery at all is done, we are 'all_ok'
host:queryDns(false) -- timer-context; cacheOnly always false
end
end
Expand Down Expand Up @@ -1380,7 +1377,7 @@ _M.new = function(opts)
}, self)

if not self.resolveTimer then
ngx_log(ngx_ERR, self.log_prefix, "failed to create the timer: ", err)
return nil, "failed to create timer for background DNS resolution: " .. err
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/resty/dns/balancer/least_connections.lua
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function _M.new(opts)
opts.log_prefix = "least-connections"
end

local self = balancer_base.new(opts)
local self = assert(balancer_base.new(opts))

-- inject overridden methods
for name, method in pairs(lc) do
Expand Down
2 changes: 1 addition & 1 deletion src/resty/dns/balancer/ring.lua
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ function _M.new(opts)
opts.log_prefix = "ringbalancer"
end

local self = balancer_base.new(opts)
local self = assert(balancer_base.new(opts))

if (not opts.wheelSize) and opts.order then
opts.wheelSize = #opts.order
Expand Down

0 comments on commit dd92320

Please sign in to comment.