fix: remove stale checker before adding new one (#3427)

lua-resty-healthcheck remove target according to the `ip, port,
hostname` tuple. If the newly added target has the same tuple, it will
be removed accidently.
This commit is contained in:
罗泽轩 2021-01-26 23:33:21 +08:00 committed by GitHub
parent 8c7a6887ec
commit a3c7c4098b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 7 deletions

View File

@ -88,6 +88,13 @@ local function create_checker(upstream)
return nil
end
if healthcheck_parent.checker then
core.config_util.cancel_clean_handler(healthcheck_parent,
healthcheck_parent.checker_idx, true)
end
core.log.info("create new checker: ", tostring(checker))
local host = upstream.checks and upstream.checks.active and upstream.checks.active.host
local port = upstream.checks and upstream.checks.active and upstream.checks.active.port
for _, node in ipairs(upstream.nodes) do
@ -98,13 +105,6 @@ local function create_checker(upstream)
end
end
if healthcheck_parent.checker then
core.config_util.cancel_clean_handler(healthcheck_parent,
healthcheck_parent.checker_idx, true)
end
core.log.info("create new checker: ", tostring(checker))
healthcheck_parent.checker = checker
healthcheck_parent.checker_upstream = upstream
healthcheck_parent.checker_idx =

View File

@ -156,6 +156,8 @@ qr/(create new checker|try to release checker): table/
create new checker: table
try to release checker: table
create new checker: table
--- no_error_log
all upstream nodes is unhealthy, use default