-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: mostly_healthy is healthy #10639
Conversation
Hi @Sn0rt |
The reason why mostly_healthy is regarded as health is because when upstream selects a node, both mostly_healthy and healthy are regarded as health. The core logic reference screenshot is from resty-helath-check. For this reason, the PR is written like this. local function fetch_health_nodes(upstream, checker)
local nodes = upstream.nodes
if not checker then
local new_nodes = core.table.new(0, #nodes)
for _, node in ipairs(nodes) do
new_nodes = transform_node(new_nodes, node)
end
return new_nodes
end
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
local up_nodes = core.table.new(0, #nodes)
for _, node in ipairs(nodes) do
local ok, err = checker:get_target_status(node.host, port or node.port, host)
if ok then
up_nodes = transform_node(up_nodes, node)
elseif err then
core.log.warn("failed to get health check target status, addr: ",
node.host, ":", port or node.port, ", host: ", host, ", err: ", err)
end
end
if core.table.nkeys(up_nodes) == 0 then
core.log.warn("all upstream nodes is unhealthy, use default")
for _, node in ipairs(nodes) do
up_nodes = transform_node(up_nodes, node)
end
end
return up_nodes
end
|
@snort Thanks for the answer, the corresponding code link is here https://github.com/api7/lua-resty-healthcheck/blob/master/lib/resty/healthcheck.lua#L684 |
Signed-off-by: Sn0rt <wangguohao.2009@gmail.com>
I agree with @luoluoyuyu's #10639 (comment). Even if logically |
This is a bugfix. I want to avoid doing meaningless things without clear requirements. apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8765"} 1
apisix_upstream_status{name="/apisix/routes/1",ip="127.0.0.1",port="8766"} 0 |
Description
fix: #10664
build a
mostly_healthy
test case based on test-nginx is too difficult for me. so this PR not include test caseI will add the test case form this metric at the next PR
Checklist