Skip to content

Commit

Permalink
fix: fix delay clean logic when multiple healthchecker was started
Browse files Browse the repository at this point in the history
  • Loading branch information
oowl committed Dec 14, 2023
1 parent 8277401 commit be15972
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/resty/healthcheck.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1650,9 +1650,11 @@ function _M.new(opts)
end

local cur_time = ngx_now()
local is_checked = false
for _, checker_obj in pairs(hcs) do

if (last_cleanup_check + CLEANUP_INTERVAL) < cur_time then
is_checked = true
-- clear targets marked for delayed removal
locking_target_list(checker_obj, function(target_list)
local removed_targets = {}
Expand Down Expand Up @@ -1681,8 +1683,6 @@ function _M.new(opts)
end
end
end)

last_cleanup_check = cur_time
end

if checker_obj.checks.active.healthy.active and
Expand All @@ -1701,6 +1701,9 @@ function _M.new(opts)
checker_callback(checker_obj, "unhealthy")
end
end
if is_checked then
last_cleanup_check = cur_time
end
end,
})
if not active_check_timer then
Expand Down

0 comments on commit be15972

Please sign in to comment.